Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: delete cookie (cgi101)

by Anonymous Monk
on May 12, 2015 at 02:25 UTC ( [id://1126371]=note: print w/replies, xml ) Need Help??


in reply to delete cookie

bigup401 why would you expect "delete" as in https://metacpan.org/pod/CGI#Deleting-a-parameter-completely to touch cookies?

Here is followup to cgi101

sub NoCookiesNoMore { my( $q, $url ) = @_; my @names = $q->cookie; my @coo = map { $q->cookie( -name => $_, -value => [], -expires => '-10y', + ) } @names; $url and return $q->redirect( -location => $url, -cookie => [@coo] + ); return $q->redirect( -cookie => [@coo] ); } ## end sub NoCookiesNoMore __END__ $ perl GoToWellwithCookiesNoMore.cgi Status: 302 Found Set-Cookie: 1=; path=/; expires=Sat, 14-May-2005 02:28:08 GMT Set-Cookie: ro=; path=/; expires=Sat, 14-May-2005 02:28:08 GMT Set-Cookie: 3=; path=/; expires=Sat, 14-May-2005 02:28:08 GMT Set-Cookie: 5=; path=/; expires=Sat, 14-May-2005 02:28:08 GMT Date: Tue, 12 May 2015 02:28:08 GMT Location: http://localhost

Replies are listed 'Best First'.
Re^2: delete cookie (cgi101)
by bigup401 (Pilgrim) on May 12, 2015 at 09:47 UTC

    i got some idea and it worked for me. by overwriting the old cookie and then the browser will delete it because it has expired

    $page = '#page'; $cookie = $cgi->cookie(-name => 'user', -value => '', -expires=> '-1d' +); print $cgi->redirect(-location => $page, -cookie => $cookie);

    it works well now. can delete the old cookie by overwriting it

      Of course it worked, thats how HTTP works

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1126371]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2024-03-28 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found