0


I have a HTML page (h1.html) which submits a form to a PHP page (p1.php) via an AJAX call. In p1.php I have:

session_start();
$_SESSION['sth'] = "some value";
// some other stuff here

Then I submit another form in h1.html in another PHP page (p2.php) without using AJAX.
The problem is $_SESSION is empty in p2.php! I call session_start() in both p1 and p2.
Any suggestion?

Pedram Behroozi
  • 2,297
  • 2
  • 27
  • 45
  • Does any of those answers help you? http://www.sitepoint.com/forums/showthread.php?627717-setcookie%28%29-inside-AJAX-request or http://stackoverflow.com/questions/3431906/setting-a-cookie-in-an-ajax-request ? – Boldewyn Oct 11 '11 at 08:18
  • 1
    do you see the session in your temp folder? tried another browser? cookies enabled? – iHaveacomputer Oct 11 '11 at 08:18
  • We're going to need some more information. Have you somehow determined that the request to p1.php is succeeding? Have you tried going to p1.php in your browser (via the address bar) and then going to p2.php? Have you tried a version that is literally just the code you posted in your question? Are you getting any errors from session_start? The more information you can tell us, the more specific help we can give. – Corbin Oct 11 '11 at 08:18
  • Check whether you receiver a new cookie each time you visit the pages. If so, then either sessions are turned off in the php configuration or the session folder is not writable. – Marius Solbakken Mellum Oct 11 '11 at 08:23
  • @iHaveacomputer Yes. Worked in IE! Doesn't work in FF. but cookies are enable in FF! – Pedram Behroozi Oct 11 '11 at 08:40
  • @iHaveacomputer. FF cookies were disabled. Thank you very much!! – Karasutengu Nov 09 '12 at 04:27

0 Answers0