PDA

View Full Version : Adding another cookie to the header.


Rakish
08-01-2006, 09:00 PM
Hi all,

I want to send other cookies along with the session;

the problem is when i send the session cookie to the header by:

print $session->header();

and then send another cookie by

print header(-cookie=>$cookie13);

PERL just prints the value of the cookie13 on the browser, this means the no cookie is created at all...

but i could see the session cookie created which is named "CGISESSID"

I would really apprecite if some one helps me with this.

Thankyou,

-Rakesh

KevinADC
08-02-2006, 08:02 PM
once the header is printed you can not send more cookies. In the CGI modules documentation under HTTP Cookies it explains how to send multiple cookies:

To create multiple cookies, give header() an array reference:

$cookie1 = cookie(-name=>'riddle_name',
-value=>"The Sphynx's Question");
$cookie2 = cookie(-name=>'answers',
-value=>\%answers);
print header(-cookie=>[$cookie1,$cookie2]);

You should be able to send your session cookies along with any other cookies using the CGI modules header() function.