I followed the wikihow tutorial for building a secure session management system : http://www.wikihow.com/Create-a-Secure-Session-Managment-System-in-PHP-and-MySQL
and it works fine.
Now, I have a problem that session id cookie _s change (and log in information) when 2 successive ajax are called like this :
<input type="button" value="go" id="mybutton" />
<script>
$("#mybutton").click( function() {
$.get("ajax1.php");
$.get("ajax2.php");
});
</script>
where both ajax1.php and ajax2.php have just require the session class file
<?php
require('session.class.php');
$session = new session();
$session->start_session('_s', false);
?>
upon clicking the button, the session id stored in _s cookie changes to a new one. I added an alert between the two ajax like this
<input type="button" value="go" id="mybutton" />
<script>
$("#mybutton").click( function() {
$.get("ajax1.php");
alert("anything");
$.get("ajax2.php");
});
</script>
by separating the two ajax calls, the session id didn't change.
EDIT: the actual code isn't like this ,, but rather many separate buttons each have it's ajax,, but it happens that a user clicks buttons successively before response.
<input type="button" value="go" id="mybutton" />
<script>
$("#mybutton").click( function() {
$.get("ajax1.php");
});
</script>
<input type="button" value="go" id="mybutton2" />
<script>
$("#mybutton2").click( function() {
$.get("ajax2.php");
});
</script>
any ideas??