Hi guys,
i've been trying to fix an issue all day and can't figure it out!
i have a php page that calls another php page through AJAX. The problem is that the session variables i set in the page i call through AJAX don't stick when i go back to the calling page.
I believe it may be because of the way i'm calling the page url with AJAX, which could be what makes another session once it gets to the AJAX page
url:"<?php echo $config->urls->templates?>logincode.php/",
the session ID's are completely different on both pages and the name of the session from the calling page is 'wire'. The name of the session on the AJAX page is called 'PHPSESSID'. So the sessions are not the same, which is why the session variables set in the AJAX page aren't available in the calling page when the AJAX page is returned to the calling page.
i've tried renaming the ProcessWire session name in the config file to 'PHPSESSID', although that didn't work.
When i go to the page 'logincode/' as a regular post from a form it works perfectly and has the same session ID and variables, although through AJAX the sessions on both pages are completely different.
Does anyone know how to do this properly and make the session the same? Please help, it's driving me mad!
see the AJAX calling code below:
$.ajax({
type : 'POST',
xhrFields: {withCredentials: true},
data : {'username':username, 'password':password},
url:"<?php echo $config->urls->templates?>logincode.php/",
success:function(result){
if(result == "1"){
alert('Please input username and password');
}
},
error:function(xhr, status, error) {
alert('error');
}
});