Thread: Set and get cookie using perl
Results 1 to 2 of 2
set multiple cookie Forum: CGI Perl ForumReplies: 0
Set-Cookie Forum: CGI Perl ForumReplies: 1
Perl cookie.... Forum: CGI Perl ForumReplies: 2
How can i execute a perl file within perl programming... Forum: CGI Perl ForumReplies: 1
cookie problem... Forum: CGI Perl ForumReplies: 2
03-15-2007, 11:22 PM #1
Set and get cookie using perl
I am working on setting cookie on perl.
when I did hard code sample cookie in the header ...
print "Set-Cookie: mycookie=testing;expires=Mon, 29-Jul-2008 15:00:00 GMT;domain=www3.cs.umanitoba.ca;path=/~umen/cgi- print "Content-type: text/html\n"; print "Pragma: no-cache\n\n";
does anyone know how to solve this problem?
Another thing is ... if I want to set the cookie after user has log in to a page and verified with his userid and password, what I can do?
I tried to use
print header(-cookie=>"Set-Cookie: name=value ....\n");
is my code right?
03-17-2007, 04:26 PM #2
Re: Set and get cookie using perl
You have the order wrong. First define the content type, then the cookie then the extra stuff if you need it.
print "set-cookie: value=$value; path=$path; expires=$expire\n\n";
That will solve your problem.
You can set your browser to warn you when a cookie is being set, that way you know when you access the page if it is working before trying to read it.