Re: $_SESSION problem - page reload creates new Session ID

From: Erwin Moller (since_humans_read_this_I_am_spammed_too_much_at_spamyourself.com)
Date: 12/10/04


Date: Fri, 10 Dec 2004 13:12:52 +0100

Mimi wrote:

> Hello,
>
> I am having trouble using the session vars in
> PHP 4.3.9
> OS: Win XP Prof
> Web Server IIS (is local and there are no links to other servers from
> the web pages I work on)
> Browser: IE 6.0
>
> The problem I am having is that each time I reload the same PHP page, I
> get a different
> Session ID (and thus all session vars are lost from one page to another).
>
> let's say in firstpage.php I set
> $_SESSION["firstvar"] = "someval";
> $_SESSION["secvar"] = "otherval";
>
> and in secpage.php I try to retrieve $_SESSION["firstvar"] , it gives me
> "Undefined Index error"
> I did not know what is happening and when printing out the session id
> (echo SID;) I found out
> that the ID is changing every time page is reloaded or when moving to
> another page.
>
> The problem is that I don't know what might reset the session since I use
> "session_auto_start"
> and have not played with session_start, session_destroy or anything else.
>
> Can someone give me a hint on what might cause this ?
>
> Thanks
>
>
>
> Settings taken from PHP_INFO:
> ==========================================================
> Session Support enabled
> Registered save handlers files user
>
> Directive Local Value Master Value
> session.auto_start On On
> session.bug_compat_42 On On
> session.bug_compat_warn On On
> session.cache_expire 180 180
> session.cache_limiter nocache nocache
> session.cookie_domain no value no value
> session.cookie_lifetime 0 0
> session.cookie_path / /
> session.cookie_secure Off Off
> session.entropy_file no value no value
> session.entropy_length 0 0
> session.gc_divisor 100 100
> session.gc_maxlifetime 1440 1440
> session.gc_probability 1 1
> session.name PHPSESSID PHPSESSID
> session.referer_check no value no value
> session.save_handler files files
> session.save_path D:\PHP\SessionData D:\PHP\SessionData
> session.serialize_handler php php
> session.use_cookies On On
> session.use_only_cookies Off Off
> session.use_trans_sid Off Off

Looks good to me.
Are you maybe jumping to another domain too when you say you jump to another
page?
Cookies are invisible when the domain changes (or even path in the same
domain in some cases)

http://www.domain1.com/somephp.php <- sets cookie with PHPSESSIONID

http://www.domain2.com/somephp.php <- invisible here

I am unsure if that is the case of course.

A great way to debug theese kind of problems is by simply investigating the
cookies set on your browser.
(Use Firefox or Mozilla for a userfriendly cookieviewer under tools)

Regards,
Erwin Moller



Relevant Pages

  • Re: Hiding variables passed via URL
    ... well you can view cookies as well. ... What else constitutes a 'session variable' apart from POST or GET data ... But then you don't understand that session variables aren't POST or GET ... You could coordinate PHP with Javascript. ...
    (comp.lang.php)
  • Re: Hiding variables passed via URL
    ... well you can view cookies as well. ... What else constitutes a 'session variable' apart from POST or GET data ... But then you don't understand that session variables aren't POST or GET ... You could coordinate PHP with Javascript. ...
    (comp.lang.php)
  • Re: PHP sessions and disabled cookies
    ... Cookies are blocked in my ... I do not see the URL containing the session ID. ... [PHP] ... A warning appears if the specified function is not defined, ...
    (php.general)
  • PHP sessions and disabled cookies
    ... I am new to this group and PHP. ... Cookies are blocked in my ... I do not see the URL containing the session ID. ... The PHP directives register_globals, ...
    (php.general)
  • Re: Looking for general advice on security
    ... PHP pages have to be world-readable, ... SSL provides a way for a thief with a browser to communicate with ... cookies because the user can't fake a session with arbitrary contents, ... Try to send a message to the user and see if the mail server ...
    (comp.lang.php)