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: Intermediate:
Cookie Monster

 



pu_nk
journeyman

Jan 24, 2001, 1:04 PM

Post #1 of 3 (223 views)
Cookie Monster Can't Post

HI am having a problem using cookies. Well this is my first time using them and i thought i would be easy but i have run into something srtange..

Wen i set the cookie i use the following code...

--------------------------------------------------------------------

print "Set-Cookie: username=$form{'username'}\|\|$form{'password'}; expires=Wed 22 Sep 2014 23:59:59 GMT;\n";
-----------------------------------------------------------------

This works fine.. Well it was working yesterday..

Now when i ask the users to log out i just use the same code above but i make the year 1969 so it is expired..

Here is my problemo.........

For some reason when i log out i dont log out anymore..

maybe it is something else.. but does anyone know much about cookies and maybe you could give me a few suggestions.. Thanks,

Drew



pu_nk
journeyman

Jan 24, 2001, 7:08 PM

Post #2 of 3 (218 views)
Re: Cookie Monster [In reply to] Can't Post

well i think i have figured out my problem on my own..

Thanks for reading anyway :)



Jasmine
Administrator

Jan 26, 2001, 9:06 AM

Post #3 of 3 (211 views)
Re: Cookie Monster [In reply to] Can't Post

My biggest suggestion would be to use CGI.pm to handle your cookies Smile

Setting a cookie is as easy as:


Code
$cookie = cookie( 
-name => 'sessid',
-value => $session_id,
-path => '/',
-expires => "+30d",
);

print header(-cookie=>$cookie);

That takes care of both your cookie, and your "content-type" line.

If you need to set more than one value in a cookies, it's still easy:

Code
$cookie1 = cookie( 
-name => 'sessid',
-value => $session_id,
-path => '/',
-expires => "+30d",
);

$cookie2 = cookie(
-name => 'name',
-value => $name,
-path => '/',
-expires => "+30d",
);

print header(-cookie=>[$cookie,$cookie2]);

Getting the value from a cookie is as easy as:

Code
my %cookie = cookie("sessid");

A little late with my reply, but I hope it helps anyway Smile


 
 


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

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