Hi monks. I have script that uses a session file to save a password, and then can reread it on subsequent calls (in a browser, not from command line). This works fine on Linux, but doesn't work on Windows (compiled with Perl2exe, not pp, sorry, bear with me, shouldn't have anything to do with it)

Here is the script:

#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html;charset=UTF-8\n\n"; print "<html><head></head><body>Start test script.<br><br>\n"; use CGI; use CGI::Session; $cgi = new CGI; $sid = $cgi->param('CGISESSID') || undef; print "Incoming sid:$sid<br>"; $SessionFilePath = 'c:\windows\temp'; $session = new CGI::Session("driver:File", $sid, {Directory=>$SessionF +ilePath}) or die CGI::Session->errstr(); $sid = $session->id(); $pwd = "test"; $session->param("pwd", $pwd); $session->save_param($cgi); $session->flush(); print "<br>sid is now $sid.\n"; exit;
The script works to put a session file with the pwd content into \windows\temp. But on a subsequent call, with &CGISESSID=xxxxxxxxxxx added to feed it the session id, it doesn't pay any attention to the session file that it created on the last run, and creates a new one each time instead.

As I said it works on Linux. I'm thinking there is a file permission problem in Windows, but I don't know what it would be or where to start looking. (I do have admin access to the server though)

I'm using \windows\temp because an outside http request didn't have permissions to create files in other places, but it worked to create the file there. That can be setup, but I thought this should work in \windows\temp. Your insights are greatly coveted. Thank-you.


In reply to CGI::Session on Windows, can't reread file by Anonymous Monk

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.