Re: Session problems

From: Date: Mon, 09 Apr 2001 18:06:22 +0000
Subject: Re: Session problems
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-6590@lists.php.net to get a copy of this message
Hi, Ok, first of all, the function session_start () should be run on each page that uses session variables. It is necessary to access, create or modify session variables. To register variables, use session_register (). Be aware that the function uses a string argument. So to register a variable named UserName, use session_register ("UserName"). Also, use the function session_is_registered () to find out if the variable is already registered in the session (otherwise you'll get the "Session variable already registered" warning). Again, this function uses string argument, so call it like this: session_is_registered ("UserName"). Once you have registered your variable, you can access it through $HTTP_SESSION_VARS or, if you have "register_globals" set to 1 in your Php.ini, directly through the variable name. Remember that you must have first executed session_start () in order to access a session variable. Here's a quick example: <? ... session_start (); if (!session_is_registered ("UserName")) session_register ("UserName"); $HTTP_SESSION_VARS ["UserName"] = whatever you want here; ... ?> I've learned sessions solely with the php.net and I must say it was a pain in the a*s. I haven't found a good tutorial on PHP sessions yet. I hope that with this you can have a good start! Oh, one last thing, John Asendorf's idea of changing the session directory is a must. Most weird error messages from session come from a wrong session dir :-). Olivier At 18:31 2001-04-09 +0100, Mark Collins wrote: >Hi there, I am trying to get my head around Sessions but not getting very >far. I can't seem to work out exactly how you keep track of the variables. >If you register a variable at the start of the page, will it then track this >variable and take it from page to page by its self, or do you have to do >something in the code to tell the session its changed, like register it >again? > >I have got to grips with most things so far, but sessions are fighting back, >are there any good tutorials on the web you can recommend? I have already >used web monkey for most things, but their session section was a bit crappy. > >Thanks > > > >-- >PHP Windows Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net >For additional commands, e-mail: php-windows-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net Olivier Hubert Technicien informatique Support technique CIEC - Constructo (514) 856-6646 Olivier.hubert@transc.com

« previous php.windows (#6590) next »