Thread: cookie removal

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

    Join Date
    Feb 2001
    Location
    Chicago, IL
    Posts
    14
    Rep Power
    0
    Hi,
    I am quite new in perl and need a help. Could someone give me some pointer as to how I can remove a cookie which has been set when a user logs out.

    thanks
  2. #2
  3. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14
    What you need to do is set what's referred to as a "session cookie", which expires as soon as the person closes their browser. When the cookie is set, don't set any expiration date/time.

    Mickalo

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Chicago, IL
    Posts
    14
    Rep Power
    0
    Thanks, But I was thinking of using or rather testing by putting the value as "loggedout". Do you think this won't work. Okay, i attaching the code below
    redirect_with_cookie
    {
    $authcookie = cookie(-name=>'ashAuth',
    -value=>'loggedout',
    -expires=>'-1m',
    -path=>'/',
    -domain=>'.ash.com',
    -secure=>0);
    $admincookie = cookie(-name=>'ashAdmin',
    -value=>'loggedout',
    -expires=>'-1m',
    -path=>'/',
    -domain=>'.ash.com',
    -secure=>0);

    print redirect(-cookie=>[$authcookie, $admincookie],
    -location=>$firstpage);
    Somehow this is not working. when as a user, I am signing off.
  6. #4
  7. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14
    The problem is, you need to set the cookie first, then do the redirect. Try this, and see if this works for you:
    Code:
    $authcookie = cookie(-name=>'ashAuth', 
    -value=>'loggedout', 
    -expires=>'-1m', 
    -path=>'/', 
    -domain=>'.ash.com', 
    -secure=>0); 
    $admincookie = cookie(-name=>'ashAdmin', 
    -value=>'loggedout', 
    -expires=>'-1m', 
    -path=>'/', 
    -domain=>'.ash.com', 
    -secure=>0);
    # Set the cookies 
    print header(-cookie=>[$authcookie,$admincookie]);
    # Call redirect
    print redirect(-location=>'$firstpage');
    Cheers,

    Mickalo

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Chicago, IL
    Posts
    14
    Rep Power
    0
    thanks for the above modified code. It is working now.
    regards
    ashok

IMN logo majestic logo threadwatch logo seochat tools logo