Re: Session Varaible Problem
| From: | Rasmus Lerdorf | Date: | Thu, 21 Mar 2002 17:29:39 +0000 |
| Subject: | Re: Session Varaible Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-89557@lists.php.net to get a copy of this message | ||
Are you calling session_start() on the subsequent pages you want to be
part of the session?
On Thu, 21 Mar 2002, Randy Phillips wrote:
> Hi,
>
> I have tried every example of creating a session variable I could find on
> php.net and have had the same results with all of them. The session
> variables get set on the initial page but that's the only place I can access
> them.
>
> I am new to php so I'm sure I have just overlooked something.
>
> Here is my latest attempt. It's a simple login page that starts a session
> when a user successfully logs in:
>
> $connect...
>
> $sql ...
>
> list($id,$first_name) = mysql_fetch_row($sql);
> session_start();
> if (!session_is_registered('user_id')) {
> session_register('user_id');
> $user_id = $id;
> session_register('user_name');
> $user_name = $first_name;
> } else {
> echo "<p>Session is set and should now be availalbe on all pages via a
> cookie. At least that what I expected.";
> }
>
> Sadly, these vars are available only on this page.
>
> echo "<p>ID: $user_id";
>
> echo "<p>Name: $user_name";
>
> Mac OSX
> Apache
> PHP 4+
>
> Thanks,
>
> --
> Rp
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>