Re: sessions

From: Date: Fri, 10 Dec 2004 04:21:57 +0000
Subject: Re: sessions
Groups: php.db 
Request: Send a blank email to php-db+get-37661@lists.php.net to get a copy of this message
Thanks to everyone that replied. All working great now thanks. Warren >>> Jochem Maas <jochem@iamjochem.com> 10/12/2004 2:47:28 pm >>> try using the $_SESSION superglobal var (google is your friend if its new to you.) no need to register (still need to do session_start() though) just do... $_SESSION['MyValue'] = array( 'name' => $username, 'level' => $account_level ); ...or something like that. (also works for objects - which is only gets really cool in php5 - be aware that classes for objects stored in your session should be loaded BEFORE you start the session.) Warren Mason wrote: > I am attempting to get information from a mysql database and then use > this in a session. Is there a trick to using sessions? For example, can > something like below be placed anywhere in a script? (I have the > session_start(); at the very top of my page.) > > > > session_register( "session_username" ); > session_register( "session_level" ); > > $session_username = "$username"; > $session_level = "$account_level"; > > > The resulting session is > > session_username|N;session_level|i:0; > > $username is set to warren and $account_level is set to 255. > > Any help would be greatly appreciated as I have gone through about 5 > books and searched the net and can't find an answer as to why this isn't > working. > > > ----------------------------------------------------- > This message is intended for the addressee named and may contain > confidential information. If you are not the intended recipient, please > delete it and notify the sender. Views expressed in this message are > those of the individual sender and are not necessarily the views of the > Mid Western Area Health Service. > ----------------------------------------------------- > <<<<gwavasig>>>> >

« previous php.db (#37661) next »