CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
an easy question:how to write cookie?

 



tack
Novice

Feb 9, 2003, 11:13 PM

Post #1 of 3 (787 views)
an easy question:how to write cookie? Can't Post

here is my code in my webpage:


Code
  

print "content-http:text/html\n";

print "Set-Cookie:user=2;expires=Mon,01-Jan-2004 00:00:00 GMT;path=/\n\n";



but the second piece of code can't work, it only output "Set-Cookie:user=2;expires=Mon,01-Jan-2004 00:00:00 GMT;path=/" in the webpage, it became some common characters.

why?could you tell me if you know it?thanx.


davorg
Thaumaturge / Moderator

Feb 10, 2003, 2:03 AM

Post #2 of 3 (784 views)
Re: [tack] an easy question:how to write cookie? [In reply to] Can't Post

Looks like a good reason for using the CGI.pm functions instead of trying to do it yourself. Your content-type header seems to have metamorphosed into a "content-http" header which probably confuses things completely.

Using CGI.pm, it would look like this:

Code
use CGI ':standard'; 

my $cookie = cookie(-name => 'user', -value => 2,
-expires => '+1y', -path => '/');

print header(-cookie => $cookie);


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


tack
Novice

Feb 11, 2003, 5:52 PM

Post #3 of 3 (773 views)
Re: [davorg] an easy question:how to write cookie? [In reply to] Can't Post

Thank you very much, davorg. i have solved the problem by your way .

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives