Re: Problem with session_is_registered

From: Date: Thu, 21 Jun 2001 18:03:29 +0000
Subject: Re: Problem with session_is_registered
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-54779@lists.php.net to get a copy of this message
hi & thx for your replies.... @chris: thats exactly what I do right now, but I consider it a "workaround", because I have to use session_register ("count"); first. the funny thing is, that when I call this page without an session id... (just check.php instead of check.php?PHPSESSIONID=2178362178blah, I disabled cookies for testing) ...PHP generates a session because of the session_register ("count"); command even though I have "session.auto_start=0" in my php.ini... If I press the refresh button of my browser I will have another session generated by PHP.......and another......and another.......and another....I think that shouldn't be. Anyway, its a very comfortable way to create loads of little (and useless) sessionfiles on my server ;) @kaab & chadwick: jepp, but session_register ("count"); also does the job. the problem is that I don't want PHP to generate a session if there is none on this page (check.php).....the only way at the moment seems to be that I: 1. session_register ("count"); (or sesstion_start();) 2. if (isset($count)) echo "everybody is happy"; else destroy_session(); // because there was an session generated "accidentely") humm. not very nice style. I expected the session_is_registered() function to check for the given vars in a session without the need of "session_start()" first. In the end its not too difficult to implement... 1. ist there a file called "sess_aSessionID" in session.save_path? [yes | no] 2. [no] -> return false; (because there is no session) 3. [yes] -> open "sess_aSessionID" and check characters for aString [found | notfound] 4. [notfound] -> return false; 5. [found] -> return true; thats it (and what I expected).....and I wouldn't be forced to start a session to find out. I haven't been lazy and read some chapters about sessions.....but still the "session_is_registered()" function looks as useful to me as a "ceil(1);". :( greetz, andi "news.php.net" <silvervelvet@gmx.de> schrieb in im Newsbeitrag: 9gss6k$kud$1@w153.z064000151.sjc-ca.dsl.cnc.net... > hi everybody, > > maybe I get smth. wrong, but as far as I know the function > "session_is_registered()" > is used to find out if a var is registered in a session... > > ok, now here is my example: > > [ index.php ] > <?php > $count = ""; > session_start(); > session_register ("count"); > $count = "1"; > ?> > . > . > . > <a href="check.php">NEXT</a> > > > > [ check.php ] > <?php > if (session_is_registered("count")) { > echo "yes, count is reg.<br>"; > } > else { > echo "no, count is not reg.<br>"; > } > ?> > . > . > . > > > now, check.php always writes "no, count is not reg.", but I don't really > understand, why! > do I have to run a -> session_register ("count"); <- before using > "session_is_registered"? > But if I do this, there is no need to check for the var with > "session_is_registered"....because > I know the var is registered.... > > maybe someone can help me out or point me to a good tutorial about > sessions.... > > thx in advance :) > andi > > > > > > > -- > 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 (#54779) next »