Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   printing other cookies along with the session cookie (http://www.go4expert.com/forums/printing-cookies-session-cookie-t1106/)

Rakish 1Aug2006 22:48

printing other cookies along with the session cookie
 
Hi all,

I want to send other cookies along with the session; :confused:

Right now i am printing the session cookie in header by:

Quote:

print $session->header();
but if i print another cookie like

Quote:

print $session->header();
print header(-cookie=>[$cookie13]);
it doesnt create the cookie $cookie13


please let me know how to do it

Thankyou...

Rakesh

pradeep 2Aug2006 12:01

Re: printing other cookies along with the session cookie
 
Hi Rakish,
Unfortunately we can't send mutiple cookies using CGI::Session's header method, for sending multiple cookies we need a different approach. Checkout the code snippet below.

Code: Perl

$session = new CGI::Session();
 $sessionCookie = $q->cookie(-name=>$session->name,-value=>$session->id); #session cookie
 $cookie1 = $q->cookie(-name=>'deepz',-value=>'deepx_cookie'); #cookie 1
 $cookie2 = $q->cookie(-name=>'cookie2',-value=>'deepx_cookie2'); #cookie 2
 print $q->header(-location=>'index.pl',-cookie=>[$cookie1,$sessionCookie,$cookie2]); #send as many cookies as you like this way


I hope this solves your problem.

Rakish 2Aug2006 20:28

Re: printing other cookies along with the session cookie
 
Pradeep,

It did solve my problem.

you are a PERL champ,

Thankyou so much,

Rakesh


All times are GMT +5.5. The time now is 19:27.