The actual page launch an $.ajax (POST)
request and the receiver.php
need to modify the $_SESSION
.
However it do not work, i don't know whether the id
of $_SESSION
is different or if i need a refresh on the page for register the modification.
I tried to transfer the session id and modifiy it with :
<?php
if ( count( $_POST ) > 1 && isset( $_POST["s"] ) )
{
session_id( $_POST["s"] );
session_start();
}
?>
but this code is ineffective...
My $.ajax
request is simple :
var s = <?php echo "'" . session_id() . "'"; ?>;
$.ajax({
url: 'jquery/receiver.php',
type: 'POST',
dataType: 'html',
data: {
s: s, // session id, useless?
// data...
},
}).done(function ( data ) {
// operations ...
}
My receiver.php
too ;
<?php
if ( count( $_POST ) > 1 && isset( $_POST["s"] ) )
{
session_id( $_POST["s"] );
session_start();
}
$_SESSION['longarray']['key'] = 'value';
?>
Finally, it is possible to modify $_SESSION
with $.ajax (POST)
? Or maybe i have only a problem because my $_SESSION
is a array
?