#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    Can anybody help.

    I've already written an application using the session management features in PHP 4.0.0. Everything works fine, except now I want to make the sessions last longer that one visit.

    Environment:
    WinNT 4.0 w/ service pack 5.0
    PHP 4.0.0
    running IIS


    I thought I could do:
    $one_month = 60*60*24*30;
    session_set_cookie_params(time() + $one_month);

    before I made the calls to session_start/register()

    Unfortunatly, it doesn't work. It seems that the value in the php.ini always takes precedence, I'm running different sites on the same server all using php and therefore need to be independant of the php.ini file for this. session.cookie_lifetime was set to 0. So I changed it to nothing/undefined, and still the called to session_set_cookie_params() didn't seem to hold. Finally I tried to hardcode some time in the distant future like 2047 or something as the lifetime of the cookie in the php.ini file, and at least when I did this the session_get_cookie_params() would return an array with that number as the expire time. However, it didnt' seem to matter because the cookies still only hold a few minutes.

    Is this because NT can't read the unix timestamp properly? Any other ideas?

    Thanks,
    Foarod
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    It can't be done this way, it will only result in
    letting the PHPSESID cookie stay longer on the client
    machine.. but it won't prevent that the garbage collector
    deletes the session after a period of time that the session
    hasn't been used.

    It's not advicable to use one session over and over again.
    there are a lot of disadvantages with that...

    If u considerer storing data over multiple sessions, for example
    personal background color for a site, then u could use a cookie
    or you could store it in a database

    ------------------
    Greetings lewi
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    Thanks,

    I've decided to set a cookie with the users login/password and restart a new session with each visit.

    Foarod

IMN logo majestic logo threadwatch logo seochat tools logo