• 11-09-2024, 17:11:52
    #1
    Merhaba,

    Bir Butonum var bu botona bastığımda $_SESSION['asama'] = "1"; verisi oluşturucam ama buton post yada get olmamalı jquary ile yapmam gerekir. Session değiştikten sonra ise sayfayı refreshleyecek. Bir Türlü jquary ile session değiştiremedim.
  • 11-09-2024, 17:14:30
    #2
    jquery ile bir php session değişimi ancak ajax işlemi ile bir end point ile sağlanabilir. Dilerseniz özelden iletişime geçerseniz yardımcı olabilirim.
  • 11-09-2024, 17:33:15
    #3
    
    <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";
    }
    ?>