Revered Monks,

I am currently working on a project that will have a members only area that requires some authentication and session tracking. Examining the excellent CPAN, I find and decide to use CGI::Session to manange my sessions. The code I am using to create my session and cookie is below.

Hosting Environment: Win32 & IIS thru Verio.

use lib ('path/to/my/lib'); use strict; use CGI qw(:standard); use CGI::Carp('fatalsToBrowser'); use Win32::ODBC; use CGI::Session; my $q = new CGI; my $session = new CGI::Session("driver:File", $q, {Directory=>'..\sess +ions'}); ---do db search---- if ($found) { $session->param("name", $memb_name); #set a cookie my $cookie = $q->cookie(-name =>'member', -value =>'test', -domain =>'.relationshiphelp.org', -expires =>"+3h", CGISESSID =>$session->id); print $q->header(-cookie=>$cookie); print $session->param("name")."<br>"; print "Found your user id <br>"; print $session->id; return 1; }
1. If I don't use CGI::Cookie explicitly and then create my cookie using it's methods directly, I never even get a cookie. The CGI.pm cookie method doesn't throw any errors, I just don't get a cookie. I installed the latest version of CGI.pm in my local lib, and no luck. I have Super Searched and Googled to no avail.

2. When I do get a cookie using the method above, it doesn't have the CGISESSID in it. I look at it with ethereal as it comes in, and open the resulting cookie in a text editor after the fact, and the sesion ID isn't there. I can print the session id variable and it appears to be generated correctly, I just can't get it in the cookie.

Is my code obviously flawed? Did I miss a caveat in my searching? I have played with CGI::Session in the past, and gotten this to work with a test script in a BSD hosting environment. Is there an issue with Win32?

Any direction is greatly appreciated.

In reply to CGI.pm, CGI::Session and Cookies by digger

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.