Thread: Session cookies

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

    Join Date
    Jul 2000
    Location
    Bremgarten, Switzerland
    Posts
    17
    Rep Power
    0
    Hi everyone,

    I wanted to ask if it's possible to set a cookie so that it expires as soon as the user closes the browser. I know how to set cookies that for a while like

    setcookie("user", "asuzuki", time()+864000);

    for ten days.

    Is this possible?

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

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    When you call setcookie, just leave out the time argument, like this:

    setcookie("user", "asuzuki");


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

    Join Date
    Jul 2000
    Location
    Bremgarten, Switzerland
    Posts
    17
    Rep Power
    0
    It works, but it's only valid for that page,
    right?
    I set the cookie like you said, then I accesssed a file in a subdirectory (same server), and then returned to the page that set the cookie, and it was gone.

    Regards,
    Alex Suzuki
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    PHP4 is your solution. Try using a session variable...
    The variable stays available as long exists any browser window. When you close all browser's windows, or session expire time is gone, session variable is history...

    Conogol
    musician@seductive.com



    ------------------
    /-----------------
    |Information=power|
    -----------------/
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Bremgarten, Switzerland
    Posts
    17
    Rep Power
    0
    Thanks,

    I thought about that earlier, but I thought cookies would be the easier solution. But I guess you're right. I'll give it a shot.

    Regards,
    Alex Suzuki

Similar Threads

  1. using session timeout without cookies
    By me_helper in forum PHP Development
    Replies: 6
    Last Post: July 27th, 2006, 02:45 AM
  2. Replies: 6
    Last Post: February 8th, 2004, 04:27 PM
  3. session without cookies
    By Vmusic in forum PHP Development
    Replies: 4
    Last Post: October 12th, 2003, 11:00 AM
  4. session / cookies problem
    By ronaldvillarosa in forum PHP Development
    Replies: 5
    Last Post: September 10th, 2003, 05:17 AM
  5. session start issue!
    By djl in forum PHP Development
    Replies: 0
    Last Post: July 29th, 2003, 01:37 PM

IMN logo majestic logo threadwatch logo seochat tools logo