I know that there are many template systems and modules available to implement
it. I have experienced using sessions. That was easy too. But cookies behave
differently. I need to understand the behavioral issues in cookies.
Now, let me put my doubt in other terms.
Please, look into the following code:
# animal is an existing cookie with value as 'lion'
my $animal = cookie('animal');
# now $animal gets 'lion'
# now assign 'tiger' to animal
my $cookiereplace = "Set-Cookie: animal = tiger;\n";
print $cookiereplace
# assignment done
my $animal_new = cookie('animal');
.....
# Question : Now what does $animal_new contain?
.....
print header;
my $animal_very_new = cookie('animal');
.....
# Question : Also, what does $animal_very_new contain?
.....
-----Original Message-----
From: Chris Devers [mailto:[EMAIL PROTECTED]
Sent: Monday, November 14, 2005 8:36 PM
To: S, karthik (IE03x)
Cc: Perl Beginners List
Subject: RE: cookies
On Mon, 14 Nov 2005, S, karthik (IE03x) wrote:
> my $username = 'name';
> my $cookiereplace = "Set-Cookie: username=$username; expires= \n";
> print $cookiereplace
>
> print header;
> ....
> #print htmls
> ....
>
> To unset the cookie :
>
> my $cookiereplace = "Set-Cookie: username='';";
Okay, that's a start, thank you.
Now, please, can you point out the documentation you were reading that
led you to believe that this would do anything useful?
I have a hunch you may have mis-read something :-)
Here's a hint: among a great many other ways to do this, the CGI.pm
module has built-in methods to handle this for you. Look up for the
cookie sections of the CGI perldoc; an online version is here:
http://perldoc.perl.org/CGI.html#HTTP-COOKIES
Additionally, higher-level modules like CGI::Application do a lot of the
work needed to make you forget that cookies are even necessary.
Documentation on it is available at
http://search.cpan.org/~markstos/CGI-Application/lib/CGI/Application.pm
But if you just want to do things the old-fashioned way with raw
cookies, don't roll your own code to do this when it's a problem that
has been solved a hundred thousand times now -- just let CGI.pm do it.
--
Chris Devers
^0%T [EMAIL PROTECTED]