printing other cookies along with the session cookie

Rakish's Avatar, Join Date: Jul 2006
Go4Expert Member
Hi all,

I want to send other cookies along with the session;

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
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
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.
0
Rakish's Avatar, Join Date: Jul 2006
Go4Expert Member
Pradeep,

It did solve my problem.

you are a PERL champ,

Thankyou so much,

Rakesh