Re: Session Code debug help requested

From: Date: Wed, 31 Jan 2001 20:29:45 +0000
Subject: Re: Session Code debug help requested
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-37532@lists.php.net to get a copy of this message
Matt, I'm not sure I understand your situation, but here's how I use sessions: 1. at the start of every PHP script, do "session_start();" 2. after session_start(), for every session variable you want to register, do "session_register("var_name");" 3. from that point forward, to give that session variable a value, that will be carried forward into other scripts (after the other script does a "session_start()"), just do $var_name = "new value"; or to print the current value of $var_name, just do echo "Value of session variable \$var_name = $var_name"; that's it. You only need to do session_destroy() when you actually want to destroy all the session variables for the current session - if you do that in every script, then you obviously won't be carrying over any session variable values from one script to the next. HTH. -- Hardy Merrill Mission Critical Linux, Inc. http://www.missioncriticallinux.com Matthew Mundy [mmundy1@gl.umbc.edu] wrote: > Hello all. > Sorry, I know sessions come up a lot. > I am attempting to use sessions for login tracking. The session starts > fine, sends the cookie fine(login as the session name), registers login as > a session var, then location should switch to index. all my files except > login include() a file called header.php which if login is not registered > redirects to login. Except login is never registered when it hits header. > The code I use to initialize the session is below. Also, no data is saved > in /tmp as it should be. I missed something. I just can't figure out > what. :( Any help would be appreciated. Thanks in advance. > ---Matt > > if ($success) > { > //set the session name to the login, start the session, > register the login in the session > //destroy any old data > @session_destroy(); > session_name($login); > session_start(); > session_register("login"); > header ("Location: index.php"); > exit; > } > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#37532) next »