Chappy,
Thanks buddy. I got clarified with this issue. Yes, it is true that there are multiple documents convey multiple things. :-) . The information from your part is valuable to me. With Best Regards, Karthikeyan S ________________________________ From: Omega -1911 [mailto:[EMAIL PROTECTED] Sent: Thursday, November 17, 2005 1:15 AM To: S, karthik (IE03x) Cc: [EMAIL PROTECTED]; Perl Beginners List Subject: Re: cookies On 11/16/05, S, karthik (IE03x) <[EMAIL PROTECTED]> wrote: 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] Hello Karthikeyan S, I think you understand how to set a "raw" cookie from what has been discussed so far. Your original question was how to set AND delete them. To delete a cookie that has been set, simply set a cookie and for the 'expire' time, set it to a date that has passed already. Also, I see a number of web sites that IMPROPERLY document cookies. When setting cookies, you should include the follow to ensure that your cookies are secure and behave properly (otherwise, the cookies set can be read by other sites, scripts, etc.): Set-Cookie: name=$name; expires=date; path=$path_to_the_application (s)_that_are_allowed_to_modify_or_delete_the_cookie; domain=$your_web_site_address; -Chappy