<button id="sessionButton">Session Oluştur</button>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("#sessionButton").click(function(){
        $.ajax({
            url: "session_olustur.php", // Session güncelleyecek PHP dosyasının adı
            type: "POST",
            data: { session_olustur: "1" }, // Gönderilecek veri
            success: function(response) {
                if(response == "success") {
                    location.reload(); // Sayfayı yenile
                } else {
                    alert("Session güncellenemedi.");
                }
            }
        });
    });
});
</script>

session_olustur.php :




<?php
session_start();

if(isset($_POST['session_olustur'])) {
    $_SESSION['session_olustur'] = $_POST['session_olustur']; // Session'ı güncelle
    echo "success";
} else {
    echo "error";
}
?>