Perl Cookie Help
Hey guys,
I'm using Matt Wright's cookie.lib (http://www.worldwidemart.com/scripts/)
I'm trying to set a cookie expiration date like this:
&SetCookieExpDate("$text_days[$wday], $mday-$text_months[$mon]-$year 00:00:00 GMT")
'
It doesn't work, even though the date generated by that code looks like this: Tue, 012-Mar-2002 00:00:00 GMT.
But when I use that date like this:
&SetCookieExpDate("Tue, 012-Mar-2002 00:00:00 GMT")
'
It works just fine. However, I need the first bit of code. Or if someone knows an easier way to set a cookie to expire after one day, please tell! Thanks!
--Edge
Wil posted this at 09:38 — 12th March 2002.
They have: 601 posts
Joined: Nov 2001
Stop! Stop, stop, stop, stop!
Walk away from the Matt Wright archive and clear your cache and bookmarks forever! Matt Wright finished writing his code back in 1998(?) and was built on Perl 5.03. His code is full of bugs and there have been many better modules written since.
One of these modules is called CGI.pm which accomodates common CGI routines - just like the one you're trying to do. It's a part of the standard Perl dist. so you don't have to download anything.
To do what you want, try this:
#!/usr/local/bin/perl
use CGI; # load CGI.pm module
my $query = CGI->new(); # create a new CGI object
$cookie = $query->cookie (
-name => 'name',
-value => 'value',
-expires => '+1d', # cookie expires after 1 day
-path => '/',
-domain => 'yourdomain.com'
);
print $query->header(-cookie=>$cookie);
- wil
Edge posted this at 23:55 — 13th March 2002.
They have: 117 posts
Joined: Mar 2000
LOL... thanks for showing me the light! Can you point me to any sites that can show me how to use CGI.pm better?
Wil posted this at 09:38 — 14th March 2002.
They have: 601 posts
Joined: Nov 2001
http://stein.cshl.org/WWW/software/CGI/
Online documentation for CGI.pm.
http://www.wiley.com/legacy/compbooks/stein/source.html
Source code examples.
If you get stuck - drop us a note in this forum and I'm sure someone will be able to help you out. I've personally got a good working knowledge of CGI.pm
Hope this helps.
- wil
Edge posted this at 17:46 — 22nd March 2002.
They have: 117 posts
Joined: Mar 2000
Okay, so now I'm trying to implement CGI.pm into my site, but it's messing up my scripts. I almost have it working, but sometimes it prints multiple headers and weird things like that. Any suggestions?
--Edge
Wil posted this at 11:20 — 31st March 2002.
They have: 601 posts
Joined: Nov 2001
Yeah, can you give us an example?
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.