RE: [PHP-DB] php session
| From: | John W. Holmes | Date: | Sun, 01 Dec 2002 15:43:13 +0000 |
| Subject: | RE: [PHP-DB] php session | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-23750@lists.php.net to get a copy of this message | ||
> I'm having a little trouble getting sessions to work properly with
php.
> I have put session_start(); on all pages before any data is printed.
The
> session will start on the first loading of the page but after a link
is
> clicked the session seems to die i have no idea why.
>
> for the links on the pages i have included the SID constant like so:
> <a href='index.php" . SID . "&action=whatever'>Link</a> but
> after a
link
> is clicked the links them appear to lose the reference to the SID
> constant so instead of looking like
>
> <a href='index.php?PHPSESS=s8743vbkuwivn7&action=whatever>Link</a>
>
> they look like
>
> <a href='index.php?&action=whatever'>Link</a>
>
> the session_start(); isn't right at the start of the pages, its a few
> lines after but none of the lines before session_start(); print any
> data, they only store data in variables...does that matter??
No, it shouldn't.
So, the links are correct on one page, and they disappear on the second
page? Is there a reason you're passing the SID in the URL and not using
cookies?
Hmmm, found this in the manual. Maybe it applies?
---
The constant SID can also be used to retrieve the current name and
session id as a string suitable for adding to URLs. Note that SID is
only defined if the client didn't sent the right cookie. See also
Session handling.
---
You may have to call session_id() with the passed value of
$_GET['PHPSESSID'] so that PHP knows what session to restart.
---John Holmes...