|
|
Posted by Rik Wasmus on 11/19/07 20:10
On Mon, 19 Nov 2007 20:49:23 +0100, Matthew <matthew@spamkiller.com> wrote:
> Rik Wasmus emailed this:
I thought I posted :P
>> On Mon, 19 Nov 2007 20:38:05 +0100, Rik Wasmus
>> <luiheidsgoeroe@hotmail.com> wrote:
>>> On Mon, 19 Nov 2007 20:25:25 +0100, Matthew <matthew@spamkiller.com>
>>> wrote:
>>>> As far as I can tell the $_SESSION['uid'] variable should be created
>>>> automatically when session_start() is called. When I retrieve this
>>>> variable however it is empty.
>>>
>>> Nope. Unless you name it that way.
>>> <http://nl2.php.net/manual/en/ref.session.php>
>>>
>>> The default 'session.name' is PHPSESSID, which you can normally will
>>> NOT find in $_SESSION, but in one of the $_REQUEST arrays (and thus
>>> obviously in $_REQUEST). $_COOKIE['PHPSESSID'] _if_ the session works
>>> with cookies, optionally in the $_POST or $_GET array in case of a
>>> transparant session id (which is not recommandable).
>>>
>>> If you choose another name for a session, this should be done with
>>> session_name('custom_name_of_session') BEFORE the call to
>>> session_start():
>>> <http://nl2.php.net/manual/en/function.session-name.php>
>
> Thanks for both replies Rik.
>
> > Addendum: if you're just curious what your session id actually is, use
> > session_id().
>
> What about the cookie, how do I retrieve that, I need to add it to a
> database table?
Trust me, you don't. The value in $_COOKIE['PHPSESSID'] is exactly the one
given to you by session_id(). (Assuming you have the default PHPSESSID
session name)
--
Rik Wasmus
[Back to original message]
|