Session problem, I am dead ... please advise :((

Discussion in 'PHP' started by and28, Jul 10, 2006.

  1. #1
    Hi!

    I will be really grateful if somebody could help me with session in php.

    I start session on each page with following methods:

    session_name ("Premium"); session_set_cookie_params(60 * 10, "/"); session_start(); //10 minutes

    In the end I have unwelcome behaviour:

    - after 9 minutes session still exists (I get page again and time I think should start ticking 10 minutes again) after next 3 minutes I don;t have session ...why ??

    - when session exists, opening new page (new process) i got the same session, why??
    (Writing application in java when i opened new window i was given new session id, opening viewer from active window i got same session, so exactly as it should be). In php it seems that all viewers have got same session ...


    that is all
    please help me, nobody can help me :((
     
    and28, Jul 10, 2006 IP
  2. Darrin

    Darrin Peon

    Messages:
    123
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm not exactly sure on the first part why your session is timing out (I think that is what you were asking).

    For the second question, if the session information is stored in a cookie, all browsers reading from the same set of cookies (all IE browsers) will have the same session. The ways around this are to either store your session information (ID) in the actual html of the page somewhere (like a hidden field) or to store the session ID as part of the URL.

    These two ways will keep the session for only that browser instance that is displaying it. In cookies all browsers will read from the same cookie, and the last one to write to the cookie is the data that will be used by all. The trouble with these two alternatives is that this information does not persist after the browser is closed. Any information to "remember" who you are needs to be somewhere in a cookie so it is there after the browser closes.

    Hope that helps...
     
    Darrin, Jul 10, 2006 IP
  3. and28

    and28 Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you for fast answer.

    Ok sec question I understand but with the first one is:

    I have thought that within 10 minutes when user get page on 8th minute for instance then time will be start going again, and then user will extend his time for next 10 minutes.

    Nowadays, when I get page 1 minute before and then 3 minutes after (after 10 minutes set time) i lost session ... why? How to solve it?

    If i wrote sth bad, i will try to explain my problem again
     
    and28, Jul 10, 2006 IP
  4. Darrin

    Darrin Peon

    Messages:
    123
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Darrin, Jul 10, 2006 IP
  5. and28

    and28 Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    maybe that will help ..... :

    wget -S address:

    HTTP request sent, awaiting response...
    HTTP/1.1 200 OK
    Date: Mon, 10 Jul 2006 19:10:49 GMT
    Server: Apache/2.2.2 (Win32) DAV/2 mod_ssl/2.2.2 OpenSSL/0.9.8b mod_autoindex_
    color PHP/5.1.4
    X-Powered-By: PHP/5.1.4
    Set-Cookie: Premium=4445883e00e2794c49d3e0ca4fb7ad34; expires=Mon, 10 Jul 2006
    19:20:49 GMT; path=/
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Content-Length: 3704
    Keep-Alive: timeout=5, max=99
    Connection: Keep-Alive
    Content-Type: text/html
    Length: 3.704 (3.6K) [text/html]

    100%[====================================>] 3.704 --.--K/s
     
    and28, Jul 10, 2006 IP