Re: sessions and registering variables ..

From: Date: Tue, 10 Oct 2000 11:54:17 +0000
Subject: Re: sessions and registering variables ..
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-19317@lists.php.net to get a copy of this message
ok .. I have sussed it ... *smile* session_register only registeres the variable as session applicable .. I don't have to unregister to do anything to it ... you can still manipulate it as a normal variable .. just that the session keeps track of the current value .. so the correct way to do this is : session_start(); // if I want to clear the value .. uncomment following line // $test=""; switch ($test){ case "yes": session_name("test"); session_register($test); print "$test"; break; case "no": session_register($test); print"$test"; break; default: print" $test <br><br> <a href=\"index.php3\">yes</a> <a href=\"index.php3\">no</a> "; break; --------------------- that solves my testing .. but i'm still having some trouble ... but I'll try and get around it .. if not .. I'lll mail again henti On Tue, Oct 10, 2000 at 12:08:55PM +0100, AJDIN BRANDIC wrote: > Have you tried doing unregister before start. I seam to remember someone > having a problem with this. > > session_unregister($auth); then > session_start(); > > On Tue, 10 Oct 2000 hentis@twilyt.com wrote: > > > hi all .. > > > > I think I'm doing something really badly wrong ... > > > > I'm trying to use sessions rather then cookies to keep the > > auth part of a site going .. since some people don't use cookies and cookies > > differe on some browsers .. > > anyway ... I did a test with > > > > switch ($auth){ > > case "yes": > > session_name("auth"); > > session_start(); > > session_register($auth); > > print "$auth"; > > break; > > > > case "no": > > session_name("auth"); > > session_start(); > > session_register($auth); > > print"$auth"; > > break; > > > > default: > > print" > > <a href=\"index.php3">yes</a> > > <a href=\"index.php3">no</a> > > "; > > break; > > > > this works fine .. once I've selected yes or no .. the session var is set and stays > > that way ... > > > > now for some reason .. int he acual code I'm doing this doesn't seem to work .. > > > > this is not the problem .. > > > > what I want to do is clear the session variables so added > > > > session_start(); > > session_unregister($auth); > > > > before the switch .. which should just display the default setting regardless if I select > > "yes" or "no" > > since the session var should be cleared once the script starts which is not whats > > happening. > > > > so in the end my script looks like this > > > > session_name("auth"); > > session_start(); > > session_unregister($auth); > > > > switch ($auth){ > > case "yes": > > session_name("auth"); > > session_start(); > > session_register($auth); > > print "$auth"; > > break; > > > > case "no": > > session_name("auth"); > > session_start(); > > session_register($auth); > > print"$auth"; > > break; > > > > default: > > print" > > <a href=\"index.php3\">yes</a> > > <a href=\"index.php3\">no</a> > > "; > > break; > > > > ok .. here thigns start getting wierd .. > > > > if I now replace session_unregister($auth) with session_register($auth) > > and add $auth="" above it .. I get the desired effect .. > > > > which is setting the sessionvar($auth) to "" but if I change it back .. I still > > get the "yes"/"no" switch stuff > > no the default page ... > > > > am I missing the whole point of this .. or am I just not seeying something obvios .. > > > > Henti > > > > > > -- > > 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 (#19317) next »