|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-14 19:00 UTC] morriss at r-can dot com
Description:
------------
I'm using the ISAPI filter in IIS6.
With register_long_arrays off, the session variables are not always saved.
Note that in my example, I found that assigning $sv=$_SESSION; always breaks it, but my webpage only does assignments like $sv=$_SESSION['idx'] yet is still broken.
setting "register_long_arrays = On" in php.ini fixes the problem.
Reproduce code:
---------------
<head><title>test.php</title></head>
<html>
<body>
<?php
session_start();
$sv = $_SESSION; //broken!
//$sv['idx'] = $_SESSION['idx']; //ok!
if (isset($_SESSION['idx']))
$i = $_SESSION['idx'] + 1;
else
$i = 0;
$_SESSION['idx'] = $i;
session_write_close();
echo '<p>SESSION START: '.$sv['idx'].'</p>';
echo '<p>SESSION END: '.$_SESSION['idx'].'</p>';
?>
<a href="test.php">test</a>
</body>
</html>
Expected result:
----------------
SESSION START: n
SESSION END: n+1
(after clicking link)
SESSION START: n+1
SESSION END: n+2
Actual result:
--------------
SESSION START: n
SESSION END: n+1
(does not change even after clicking link. Note that older session data is kept, if idx=3 when requesting the test page, then n=3)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 08:00:02 2025 UTC |
Hello, I have the same problem on Linux. Calling 'session_write_close' with 'register_long_arrays = Off' in php.ini will save session data incomplete. With 'register_long_arrays = On' the data is saved completely. Linux: 2.6.16 PHP: 5.2.0 Apache: 2.0.59 Reproduce code: file: session.php <?php $systems = array(); $systems['sys1'] = array('par1' => 'val1', 'par2' => 'val2'); session_set_cookie_params ( 0 , '/' , '' , FALSE ); session_start(); setcookie( 'origin' , 'localhost' , 0 , '/' ); $_SESSION = array_merge( $systems , $_SESSION ); $_SESSION['user']['login'] = 'user02'; session_write_close(); var_dump($_SESSION); echo '<a href="read_session.php">Continue</a>'; ?> file: read_sesssion.php <?php session_start(); var_dump($_SESSION); ?> Session file bad login|s:6:"user02"; Session file good sys1|a:2:{s:4:"par1";s:4:"val1";s:4:"par2";s:4:"val2";}user|a:1:{s:5:"login";s:6:"user02";}