printing other cookies along with the session cookie

Discussion in 'Perl' started by Rakish, Aug 1, 2006.

  1. Rakish

    Rakish New Member

    Joined:
    Jun 30, 2006
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    0
    Hi all,

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

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

    but if i print another cookie like

    it doesnt create the cookie $cookie13


    please let me know how to do it

    Thankyou...

    Rakesh
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    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:
    $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.
     
  3. Rakish

    Rakish New Member

    Joined:
    Jun 30, 2006
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    0
    Pradeep,

    It did solve my problem.

    you are a PERL champ,

    Thankyou so much,

    Rakesh
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice