Trouble with retrieving session variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Avinash Korwarkar

    #1

    Trouble with retrieving session variables

    Hi Guys,

    I am using sessions to store the login name and then retrieve it on
    every page. Here are the details of the php settings.

    1) I have PHP 4.2.2 installed on a Apache 1.3.27 server.
    2) I have register_global s off.
    3) I use $_session['loginname']= $loginname to store the loginname
    into the session and then retrieve it on other pages using a
    $HTTP_SESSION_V ARS['loginname'].

    My problem is that sometimes, I am able to retrieve the loginname from
    the session and sometimes I am not. When I am not able to get the
    loginname, I refresh the page 3-4 times and the loginname shows up.
    This happens on every page. Am I screwing up somewhere? Does this
    depened on the speed of the server?

    Thanks for your help.
  • Erwin Moller

    #2
    Re: Trouble with retrieving session variables

    Avinash Korwarkar wrote:
    [color=blue]
    > Hi Guys,
    >
    > I am using sessions to store the login name and then retrieve it on
    > every page. Here are the details of the php settings.
    >
    > 1) I have PHP 4.2.2 installed on a Apache 1.3.27 server.
    > 2) I have register_global s off.
    > 3) I use $_session['loginname']= $loginname to store the loginname
    > into the session and then retrieve it on other pages using a
    > $HTTP_SESSION_V ARS['loginname'].
    >
    > My problem is that sometimes, I am able to retrieve the loginname from
    > the session and sometimes I am not. When I am not able to get the
    > loginname, I refresh the page 3-4 times and the loginname shows up.
    > This happens on every page. Am I screwing up somewhere? Does this
    > depened on the speed of the server?[/color]

    Hi Avinash,

    No, not the speed of the server.

    Check the following:
    1) Do you ALWAYS start your php-scripts with session_start() ??
    Or
    Alternatively: did you put session.auto_st art = 1 in your php.ini file?\

    2) Be sure you did not produce any output before the first session-calls.

    3) To debug, check the coockies in your webbrowser. Delete them, log in
    again, check what is set, etc.etc. You can also check the real content of a
    session by finding the right one in the temp-directory as set in php.ini
    (On my system: session.save_pa th = /tmp)

    4) Last but not least: I had trouble with PHP-sessions too under 4.2 that
    was soo darn vague and difficult to replicate, I got a real headage of it.
    I upgraded to php4.3, problems gone....
    (I could only find some scattered remarks on this, not a lot.)

    Good luck,
    Regrads,
    Erwin Moller

    Comment

    Working...