I'm playing around with CGI::Session (using MySQL as the driver) and I'm having a problem with the cookie end of things. The session gets created and stores the information into the database, but for some reason, it's not saving a cookie file to my local browsers settings (IE).

In the CGI::Session Tutorial documentation, it says to write a cookie like so:
$cookie = $cgi->cookie(CGISESSID => $session->id); print $cgi->header( -cookie=>$cookie );

I read somewhere that a cookie won't be written locally unless " -path => '' " isn't set when creating your cookie (read this on another forum, may not be correct). Looking at CGI's documentation, I see that a cookie would be invoked like this:
$cookie = $query->cookie(-name => 'sessionID', -value => 'xyzzy', -expires => '+1h', -path => '/cgi-bin/database', -domain => '.capricorn.org', -secure => 1); print $query->header(-cookie=>$cookie);


How do I work with the CGI object so that I can use CGI::Session and also write the cookie to the browser? I seem to be able to only do one or the other (I can write the cookie, but then my session doesn't seem to work, or I can get the session working, but the cookie doesn't get written).

"My" code is just the examples from the CGI::Session Cookbook at this point - I'm just trying to get it to work.

djw

In reply to Trouble writing a cookie with CGI::Session by djw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.