Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Thanked 0 Times in 0 Posts

    problem with users being logged in

    I have tried a lot of things over the past week to try and keep a users session from being deleted, but it seems that after a few hours the user will be logged out and their old session will not be restored.

    I have done the following in my code:

    PHP Code:
    ini_set('session.cookie_lifetime', (60*60*24*365)); 
    ini_set('session.gc_maxlifetime', (60*60*24*365)); 

    $expiry 60*60*24*365//1 year 
    setcookie(session_name(),session_id(), time()+$expiry"/"$cookie_domain0); 

    with not much luck, is there something i am missing?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    frankfurt, german banana republic
    Thanked 0 Times in 0 Posts
    From the manual page of ini_set():

    The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.
    So you temporarily disable the GC for sessions as long as your script runs, and after it finishes, the old settings are restored, and your session get's deleted sometime later.

    You need to adjust these settings directly in your php.ini file. Perhaps it's also possible to achieve the desired results through using a .htaccess file, but you may need to set an alternative session_save_path, so your "permanent" sessions do not reside in a directory that gets occasionally sweeped by another PHP application, which uses sessions.

    However, I wouldn't do this! Sessions are designed to be only short-lived tokens to identify a client to the server, and to persist data within them. If you need a "permanent" login status for your users, send only a cookie.
    De gustibus non est disputandum.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts