RE: [PHP] $_SESSION
| From: | John W. Holmes | Date: | Tue, 15 Oct 2002 23:45:16 +0000 |
| Subject: | RE: [PHP] $_SESSION | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120081@lists.php.net to get a copy of this message | ||
> Hi All,
> still trying to update old code. Am I using $_SESSION properly?
>
> <snip>
> if (mysql_num_rows($res) ==1){
> /* If correct start session*/
> session_start();
> $_SESSION['SESSION_UNAME'];
> $SESSION_UNAME = $user;
>
> header("Location: welcome.php");
> mysql_free_result ($res);
> </snip>
Nope. Just use $_SESSION['SESSION_UNAME'] = $user;
You can treat $_SESSION just as you would any other array.
$_SESSION['something'] = "whatever";
etc... Then, on any page with session_start(), you have the whole
session array available to you, no matter what page the variable was
initially created on.
FYI: use unset($_SESSION['SESSION_UNAME']); to erase a session variable.
---John Holmes...