Re: session
| From: | Peter Beckman | Date: | Thu, 05 Jun 2003 04:11:56 +0000 |
| Subject: | Re: session | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-28336@lists.php.net to get a copy of this message | ||
Also, you don't register values, you register variables.
$id = 123;
$name = "leooi";
$_SESSION['id'] = $id; // same as session_register("id"), but better
$_SESSION['name'] = $name; // same as session_register("name"), but better
You could also skip the whole variable setting and just do this:
$_SESSION['id'] = 123;
What I like to do is this (and yes, I know, the brackets cause additional
overhead):
$r = db_query("select * from user where username='{$un}' and
password='{$pw}'");
$_SESSION['user'] = mysql_fetch_object($r);
Now anything in the user table is now accessible in my session:
if ($_SESSION['user']->id) { do something for the user that's logged in }
Peter
On Thu, 5 Jun 2003, heilo wrote:
> well - this is not really a DB-question. and if you take a look at the
> php-docu at
> http://www.php.net/manual/en/language.variables.predefined.php
> you'd see that you can access and alter them with $_SESSION or
> $HTTP_SESSION_VARS (older versions of php).
>
> leooi@hotmail.com <leooi@hotmail.com> wrote@05.06.2003 3:34 Uhr:
>
> > Hi all,
> > I had create a session and stored some value into session.
> > <?php
> > session();
> > session_register("id 123","name leooi");
> > ?>
> > How can i retrieved the value???
---------------------------------------------------------------------------
Peter Beckman Internet Guy
beckman@purplecow.com http://www.purplecow.com/
---------------------------------------------------------------------------