Hi Perl monks. I have a quandry about ActivePerl on Windows NT, and CGI::Session. I have a script that is supposed to do a simple task: create a session file in a folder on NT and store a value in it. Then I can retrieve the value later in a second call to the script. This is intended to be done in an internet browser, but for now I'm just using the NT command prompt to debug. Here's the script:

#!/usr/bin/perl use CGI; use CGI::Session; use CGI::Carp qw(fatalsToBrowser); $cgi = new CGI; $sid = $cgi->param('CGISESSID') || undef; $destdir = 'd:\web\libsearch'; $session = new CGI::Session("driver:File", $sid, {Directory=>$destdir} +) or die CGI::Session->errstr(); $sid = $session->id(); print "<br>sid=$sid, $destdir\n"; #store the variable $testvalue = "abc"; $session->param("testvar", $testvalue); $session->save_param($cgi); #retrieve the variable $retrieved = $session->param("testvalue"); print "<br>retrieved:$retrieved \n"; exit;
As it is, no file is created in the 'd:/web/libsearch' folder. If I use
$destdir = File::Spec->tmpdir;
instead of a hardcoded folder, I get the logged-in temp folder for administrator (which is how I am logged in), and the file is created & all is good. The hardcoded folder has 'everybody' listed for permissions, so it shouldn't be a permissions issue.

If I compile it into an exe (with Perl2Exe - any comments on that?) and run it from a webbrowser like I intend to do eventually here, it uses c:\winnt\temp as the temp folder value, and still no file gets created. (also no file with the hardcoded value).

Why is it unable to create a file in some circumstances? My permissions don't seem to be a problem, so what is happening in CGI::Session that it doesn't like the other folder? Thanks in advance! Michael


In reply to CGI Session - not creating session file by mwhiting

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.