I am building an order system and there are 2 different parts for adding products. In both parts, the products are inserted with an ajax request, which returns the basket. In the first part the products are directly added (without any 开发者_开发百科options). This part works fine. In the second part, users can add preferences to the ordered item. When the user clicks on a link, a facebox popup is opened. Here the user can select the preferences. When the user submits the form, an ajax call is made to the same script. So I look at the $_SESSION variable, and it appears to be empty...
The session is started, the session name and session Id are the same as on the real page, but the array is empty. When I refresh the page, the data I have added is also added to the $_SESSION variable, but not when I make the ajax call... I have added the session name and id in the url, but it still doesn't work.
Does somebody have an idea of what can go wrong. The code normally works just fine...
The session is started in a file named connection.php. In the basket I added this code:
if(!session_id()) {
$id = $_GET[session_name()];
session_id($id);
session_start();
}
This is added to the javascript:
//config:
$.sid = '<?php echo(session_name() . "=" . session_id()); ?>';
// in the request function ($(this) is the form):
var qry = '?action=add&' + $(this).serialize() + '&' + $.sid;
Gr
If session_start present before
session_start();
....
$id = $_GET[session_name()];
if (session_id() != $id) {
session_write_close();
session_id($id);
session_start();
}
精彩评论