Certain visitors are losing sessions when getting redirect to pages.
pages have session_start();
on them, I am using window.location.href
to
redirect users after success from ajax response. while this is not
happening to me using Chrome or Android. but its happening to other devices
which I cant replicate but received complaints. is there a remedy for this? we are on HTTPS. we remove the .php using nginx.
JS Code:
$(function (){
$(".my_button").click(function(e){
$.post("/post", {id: 1,blah:1},
function(data){
if(data.success){
window.location.href = data.next_page;
//Example
//window.location.href = "thankyou";
}
}, "json");
return false;
});
});
Next Pages:
<?php
session_start();
$echo = "test";
?>
/post
<?php
session_start();
$blah = $_POST['blah'];
if($blah == 1){
$next_page = "thankyou";
}else if($blah == 2){
$next_page = "back";
}
$response = array('success' => true,'next_page' => $next_page);
print json_encode($response);die();
?>
checker.php
<?php
session_start();
if(!isset($_SESSION['my_id'])){
header("Location: index.php");
exit;
}
?>