Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: CGI::Session cookie won't delete

by hippo (Bishop)
on Mar 21, 2019 at 10:24 UTC ( [id://1231526]=note: print w/replies, xml ) Need Help??


in reply to CGI::Session cookie won't delete

You have not declared $session in logout.cgi. strict would have caught that - always use strict! Also, always read the error log as the warnings which would also alert you to this bug will be in there.

Replies are listed 'Best First'.
Re^2: CGI::Session cookie won't delete
by underTheRadar (Acolyte) on Mar 22, 2019 at 08:28 UTC

    Here's the updated code:

    #!/usr/bin/perl use warnings; use CGI::Session '-ip_match'; use CGI; my $session = CGI::Session->load(); $session->delete(); $session->flush(); my $url = "https://xxxx.xxx"; print "Location: $url \n\n";

    And it's still not working

    2019-03-31 Athanasius changed <h1> to <h3>

      And you still haven't used strict. Why is that?

      Just because you fix one bug it does not mean that your code is now bug-free nor does it mean that your algorithm has been correctly coded. You said:

      The problem is, I can't remove the cookie using $session->delete() and $session->flush() when I try to log out.

      How do you expect either of those methods to delete a cookie from the jar when you are printing the response headers by hand? That's not going to happen. Either look in the code and/or the documentation and determine how you can delete a cookie using the module methods or else do it yourself in the headers if that's the way you prefer.

      Or alternatively, just don't worry that a browser still has a cookie for a now-deleted session because it's not like they can do anything with it.

      Either way, at least you are now deleting the session which you were not before.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found