sessions and registering variables ..

From: Date: Tue, 10 Oct 2000 10:38:36 +0000
Subject: sessions and registering variables ..
Groups: php.general 
Request: Send a blank email to php-general+get-19311@lists.php.net to get a copy of this message
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

« previous php.general (#19311) next »