NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP $_SESSION

David Krings ramons at gmx.net
Thu Jun 5 13:21:58 EDT 2008


Hi!

I found that calling session_start() before doing anything else seems to be 
the only way to make that work reliably. I make sure that it is the first 
thing a script executes.

Also, just as a test, add this at the top of the script
<pre>
<?php
session_start();
print_r($_SESSION);
exit;
?>
</pre>

If that doesn't show any results something is really wrong and you may want to 
take a look at the error logs. If you are looking for specific keys, did you 
write anything to the session? And watch out for typos. I can't tell you how 
often I was about to jump behind a bus just because I missed a friggin "n" or "e".

David

anthony wlodarski wrote:
> The better question is how do you build it currently?  Without that I 
> can't figure out how it might be breaking.  Also don't forget to call 
> session_start(); otherwise $_SESSION won't resume where it left off.
> 
> -Anthony
> 



More information about the talk mailing list