|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-03-06 13:11 UTC] phpbug at ehrlichorg dot com
Several pages that worked in PHP 4.0.2 no longer work in 4.1.2. The problem is that values added to a global session variable array just before jumping to another page are not being stored.
For example, on page courses.php the user selects a course from a list. The code for the course is stored in a session variable $S[event_code], and the code pagejumps (by calling a library routine that calls header()) to page course.php, to display data for that particular course. The problem is, the value $S[event_code] no longer exists when we get to the second page (course.php).
I can see the value in $S[event_code] if I var_dump($S) before the pagejump in courses.php. If I var_dump($S) just after arriving in page course.php, I see the other contents of the $S array but not $S[event_code].
Array $S is global and each page begins with
session_register("S");
The update takes place within a function that declares $S as global.
If I replace
$S[event_code] = $event_code;
with
$_SESSION[S][event_code] = $event_code;
the value is passed.
PHP options enable_track_vars and register_globals are ON, session.save_handler is files, session.serialize_handler is php.
Thank you.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 12:00:01 2025 UTC |
I experienced a similar problem (PHP 4.1.2, Linux 2.2.19-6.2.11) Works: onepage.php ----------- session_register("newvar"); $newvar = 123; header("Location: somepage.php"); somepage.php ------------ echo $_SESSION["newvar"]; //echoes 123 Doesn't work: onepage.php ----------- $_SESSION["newvar"] = 123; header("Location: somepage.php"); somepage.php ------------ echo $_SESSION["newvar"]; //"newvar" isn't set hereInteresting workaround: session_register("lastaction"); session_register("userip"); session_register("lines"); // etc etc $HTTP_SESSION_VARS["xx"] = "Anything"; // this is the magic bit Although xx isn't a registered session var, and doesn't get stored in the session, it seems to stimulate PHP to update the session vars in the file! With that addition, my apps now work fine under 4.1.2.. (Win 2k, Apache 1.3.23) John