how could i keep the session and use fewer system resource

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

    how could i keep the session and use fewer system resource

    I need to realize such an effect. if one user has login, the session
    will keep until he logout.
    but if i change the set of session.gc_maxl ifetime it will take too much
    system resource.

    i plan to create a session and insert session_id, session_data into
    database
    and create the cookie set the lifetime = 9999999999
    then when the user visit the site again, i read the cookie first to
    sure has he logined
    and match the data with the database.

    i don't know the plan will affective or not.

    ps. i don't know if i change the value of session.cookie_ lifetime,
    which will change the default cookie lifetime in the cookies.

  • Erwin Moller

    #2
    Re: how could i keep the session and use fewer system resource

    Gucci wrote:
    I need to realize such an effect. if one user has login, the session
    will keep until he logout.
    but if i change the set of session.gc_maxl ifetime it will take too much
    system resource.
    Does it really?
    'Inactive' sessions only take up a few bytes in a file in a tempdirectory,
    unless you store huge amounts of data in your sessions.

    Storing huge amounts of data in a session is bad, so don't. :P

    Did you actually measure a system/performance degradation with higher
    gc_maxlifetime?

    >
    i plan to create a session and insert session_id, session_data into
    database
    and create the cookie set the lifetime = 9999999999
    then when the user visit the site again, i read the cookie first to
    sure has he logined
    and match the data with the database.
    Yes, that is the way to go if your want to use 'user' sessionmanageme nt
    instead of 'file' which is PHP default system to store sessions.

    Check out www.php.net and look up sessions.
    You will find links to user-defined sessionstorage.
    You will also find a usefull link to the ZEND website that contains an
    example of how to achieve this with a database.

    Regards,
    Erwin Moller
    >
    i don't know the plan will affective or not.
    >
    ps. i don't know if i change the value of session.cookie_ lifetime,
    which will change the default cookie lifetime in the cookies.

    Comment

    • Gucci

      #3
      Re: how could i keep the session and use fewer system resource

      thank you Erwin, and i'm glad to say i haven't actually set
      gc_maxlifetime in a huge numer, but i really need to store a lot of
      data in session. lucky, you gave me a clear guide and thank you again.

      regards,
      Gucci Koo

      Comment

      Working...