The problem I've got is that I'm calling a php script on my server via XMLHttpRequest from a page that has already a session cookie set. The problem is that the script called by my page creates a new session_id for each call and does not use the existing one to store, the information I want to set, in it. Any solutions?
Best regards, pbcoder
The problem I've got is that I'm calling a php script on my server via XMLHttpRequest from a page that has already a session cookie set. The problem is that the script called by my page creates a new session_id for each call and does not use the existing one to store, the information I want to set, in it. Any solutions?
Best regards, pbcoder
Share Improve this question asked Aug 8, 2011 at 10:48 Pascal BayerPascal Bayer 2,6138 gold badges33 silver badges51 bronze badges 1- 1 How is your session id transported from client to server normally? By a cookie or as a query parameter or both? – hakre Commented Aug 8, 2011 at 10:54
2 Answers
Reset to default 4You're probably regenerating the session in your server side file .... can you post the part that checks the session here ? You can set a specific session id using session_id ( http://php/manual/en/function.session-id.php) in PHP.
set SID var in your XHR
$id_from_xhr_get_or_post_var=$_GET["SID"]; // or $_POST["SID"]; if you're using post
session_id($id_from_xhr_get_or_post_var);
session_name("your_session_name");
session_start();
You can store the old id in a hidden form field. It is then sent along with the rest of your XHR form data to the AJAX handling script.
<input type='hidden' name='oldsession' value='<?php echo session_id(); ?>