|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-08-04 08:09 UTC] mbeers at udeco dot com
If you take a form with a textfield on it and enter some text, including hit enter a couple of times, and store that information in a session variable, when you later try to access that variable (or any variables registered after that one) it is invalidated. It seems that when the session file is created, the newline character creates a second line (on win32 anyway) and I suppose that the code that reads the encoded session reads a line at a time, thereby missing the second line of information and invalidating any variables occurring after the one with newline charaters in it. We worked around this particular problem by replacing \n with another character, and this kept the session intact. (Please note that the \r character remained in the string, but win32 of course does not recognize that as eol) This was only tested on IE5, but not Netscape or earlier versions of IE. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 23:00:01 2025 UTC |
Here is some sample code to reproduce the problem: <? session_start(); session_register("beforeLF"); session_register("testVarLF"); session_register("testVarNoLF"); $beforeLF = "A string before that with linefeeds"; $testVarNoLF = "A string without linefeeds"; $testVarLF = "A string with linefeeds\nmore\nmore\n"; print "click <a href=\"test2.php\">here</a> to continue<br><br>"; ?> beforeLF: <pre><?= $beforeLF ?></pre> end; <br><br> testVarLF: <pre><?= $testVarLF ?></pre> end; <br><br> testVarNoLF: <pre><?= $testVarNoLF ?></pre> end; in another file (in this case called test2.php): <? session_start(); ?> beforeLF: <pre><?= $beforeLF ?></pre> end; <br><br> testVarLF: <pre><?= $testVar ?></pre> end of the output of the testVar <br><br> testVarNoLF: <pre><?= $testVarNoLF ?></pre> end; On my system, the variables don't print out at all. However, if you comment out the $testVarLF variable in the first file, everything comes out fine. (except of course a value for that variable, because it is not set). Also, if you change it to not include newline characters, it works.