1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to remove or clear Cookies when closing Browser in PHP

Discussion in 'PHP' started by praveen_design, Aug 17, 2009.

  1. #1
    Problem:

    My client said like cookies should expire in 2 hours and if the user close the browser before 2 hours then automatically clears the cookies.

    Solution:

    Just don’t put expire date. thats all.

    for more articles. http://wordpressblog.calliarc.com/
     
    praveen_design, Aug 17, 2009 IP
  2. hostrs.com

    hostrs.com Peon

    Messages:
    157
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    actually cookies dont expire right after you close the browser.. php sessions do.
     
    hostrs.com, Aug 17, 2009 IP
  3. praveen_design

    praveen_design Peon

    Messages:
    156
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No, It will expire if that above case
     
    praveen_design, Aug 18, 2009 IP
  4. hostrs.com

    hostrs.com Peon

    Messages:
    157
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    try it.. i just did
     
    hostrs.com, Aug 18, 2009 IP
  5. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It's actually the reverse, the cookies expire but the sessions remain (until it's automatically cleaned up). Then, next time you open your browser, you'll get a new cookie which also means a new session id so it won't attach to your old session.
     
    premiumscripts, Aug 18, 2009 IP
  6. stila

    stila Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    In my view the normal setting of the cookies and session record in most cases is that the cookies expire, and the session remains attached (untill it is ceared automaticly.
     
    stila, Aug 28, 2012 IP
  7. InstaCoders

    InstaCoders Peon

    Messages:
    53
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I avoid both and use sessions when needed for like logins and such. Anything that pertains to needing to know the user is 'there' - sessions is the way I approach it, even if it means just storing their ip in a session or under and md5 without a login.

    Too many inconsistencies in my book for 'cookies' or php_sessions
     
    InstaCoders, Aug 28, 2012 IP