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

Re: How can I maintain a session cookie

by Anonymous Monk
on Feb 05, 2000 at 09:32 UTC ( [id://2896]=note: print w/replies, xml ) Need Help??


in reply to How can I maintain a session cookie?

First of all use the CGI module, it'll make your life easier in general, not just dealing with cookies.
use strict; use CGI qw(:standard); $q = new CGI; # Create a 11 character random string as a # session id. (Yes, it's swiped from the perl cookbook:-) @chars = ( "A" .. "Z", "a" .. "z", 0 .. 9 ); $usersession = join("", @chars[ map { rand @chars } (1 .. 11) ]); # Set a cookie that expires when # the user closes their browser $initcookie = $q->cookie( -name=>'User_Session', -value=>$usersession, -expires=>'', # leave this blank -path=>'/', -domain=>'www.somewebsite.com', -secure=>0 ); print $q->header(-cookie=>$initcookie);
For more info on the CGI module, go to: http://stein.cshl.org/~lstein/ Shawn

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-29 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found