One way or another the session must be destroyed! [topc concerning session_destroy()]

Discussion in 'PHP' started by bartolay13, Nov 7, 2007.

  1. #1
    hello frends,

    just want to ask questions, or advice about destroying a session..
    i am now into a series of question in my head..
    *how to destroy a session when a session did not undergo session_destroy()
    *how to "not" to destroy a session or to destroy it for example
    in some instances, power failure.
    *and how to set a session expire within a given time..

    please help me on this..
    thanks in advance.
     
    bartolay13, Nov 7, 2007 IP
  2. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    -To destroy the session without session_destroy() you will have to manually kill the session cookie and remove all session variable using unset. This has the desired effect but isnt optimal.
    -You cant really hold onto a session. The only way around this is to set your own session cookies with an extended expiry time and store any session variables in the database or memory
    - Take a look at PHP's session_set_save_handler it allows you to overwrite PHP default session functions or simply use session_cache_expire($expireTime)

    It sounds like you need functionality outside what PHPs session handlers are designed to do. You might want to have a crack at creating your own session class. That way it can do exactly what you want :)

    Good Luck!
     
    tonybogs, Nov 8, 2007 IP
  3. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #3
    thanks man, some say that setrawcookie() function will do the trick,
    anyways ill try session_cache_expire instead..

    any other more suggestions?
     
    bartolay13, Nov 8, 2007 IP