Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cookies

Status
Not open for further replies.

shaolinf

Programmer
Nov 20, 2007
14
GB
Hi guys,

If I want to set a cookie that will last for an hour how will I do that ?
 
There's an expire field in the cookie: you can google for this.
However this is not a perl argument, though you are possibly using perl to code. You should post this in a more appropriate forum, also describing the environment in which you are working.

Franco
: Online tools for structural design
: Magnetic brakes for fun rides
: Air bearing pads
 
show the code you're using to generate the cookie ...

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Im using this on index page to check if the cookie exists:

$rcevd_cookies = $ENV{'HTTP_COOKIE'};
@cookies = split /;/, $rcevd_cookies;
foreach $cookie (@cookies)
{
if ($cookie eq "login=true")
{
print "<META HTTP-EQUIV=refresh CONTENT=\"0;URL=frontpage.cgi\">\n";
}

This is how the cookie is made in the login page:

if ($formhash{'remember'} eq '1') {
$time=gmtime(time()+3600)." GMT"; $cookie = "login=true; path=/; expires=$time; $secure";
print "\n";
}

The cookie is made in login page and checked on index page. It doesn't work though, any ideas ?
 
I'd stongly recommend using the CGI library. You're going to be constantly tripped up by the complexities of http otherwise and end up reinventing a lot of wheels.

Yours,

fish

[&quot;]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life was going to be spent in finding mistakes in my own programs.[&quot;]
--Maurice Wilkes, 1949
 
fish is correct, the CGI module is built for this sort of thing, and should be included as part of the core perl distribution.

The code you've displayed should be setting the cookie, have you checked the cookie value using browser tools to see what's in there?

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
I'm pretty sure every question you've asked now has had a response of "You should be using the CGI module". You might think about it. You should never store anything in a cookie other than a session id as they are not secure. You should use sessions to keep all of your data in.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top