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.
PHP Session Change Jquary
2
●70
- 11-09-2024, 17:33:15
<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"; } ?>