1

Possible Duplicate:
Session lost after page redirect in php

Help, I store a sting value of length 771 in a session variable. Problem is when I do a page redirect, the session variable becomes empty, the string value is lost. Can anybody help? code example:

$_SESSION['text'] = $text; //$text is a string of length 771
header('location:index.php');
exit;

I already have session_start() on every page that uses sessions. The problem is coming from the length of the string. When I store a string of shorter length in the session variable, I am able to successfully retrieve it when I redirect. However, once the length of the string is up to 500, I am no longer able to retrieve it

Community
  • 1
  • 1
NaijaProgrammer
  • 2,892
  • 2
  • 24
  • 33
  • Are you using a customer session_save_handler at all? or straight forward sessions? If you have a customer handler, saving to database (for example) then check that the database field is long enough to store the session. – Robbie Oct 13 '12 at 10:42
  • @Robbie, Yes I am using a custom session handler class with values stored in a mysql database. The field that stores the session data is of type text, which I believe should be able to store a string that size. or am I wrong? – NaijaProgrammer Oct 13 '12 at 10:49
  • To see what I mean, go to www.trend-this.com. If you trend a short post, you can see your post displayed. But once it's that long, You won't be able to see your post – NaijaProgrammer Oct 13 '12 at 10:52
  • "Text" is long enough, yes. 64kb. Double check your handler that you're not limiting the length using substring - or if you have a class that handles database calls, check that isn't limiting the length in some way. You can also check by looking at the saved data - does it look complete? – Robbie Oct 13 '12 at 11:03
  • @Robbie, I just checked the database, yes the saved data is complete, the full string is there. But it doesn't get passed to the redirected page, every other session variable and value gets passed, except this string – NaijaProgrammer Oct 13 '12 at 11:21
  • Rename it as "text2" and see if this works. You might have something else overwrite "text". – Robbie Oct 13 '12 at 11:37
  • Thanks for all your help. I finally found the problem was caused by excessive white-space within the string. Thanks, Robbie – NaijaProgrammer Oct 13 '12 at 12:25

0 Answers0