Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Regarding session path

by Anonymous Monk
on Apr 21, 2004 at 07:50 UTC ( #346923=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all.
I have to create a session using the following line
$session = new CGI::Session(undef, $cgi, {Directory=>'/tmp'});

Im running perl scripts on windows 2000 professional machine and IIS as web server.
In the above code line, in place of "/tmp", what is the correct syntax of the path, i have to give to store the session variable in my windows machine.
I mean, "/" type of path representation is used in unix.
What type of representation i have to give for windows machine.
I have tried giving "C:\temp" , "C:\\temp" , "C:/temp".
But nothing has worked properly.
it's also not giving error message.
Thing is that , I have to access the sesion variables in next page, but there it is unable to find the existing session and creating new session.
This is the problem.
pls could anyone help me. Thank you in advance.

Replies are listed 'Best First'.
Re: Regarding session path
by muntfish (Chaplain) on Apr 21, 2004 at 08:55 UTC

    I would have thought that "C:\\TEMP" should work (assuming that C:\TEMP actually exists?).

    For a more portable solution you might want to look at the File::Temp module:

    use File::Temp qw(tempdir);
Re: Regarding session path
by TilRMan (Friar) on Apr 21, 2004 at 10:55 UTC
    Dunno about IIS, but Windows 2000 has the environment variables TEMP and TMP.
    # Untested my $tempdir = $ENV{TEMP} || $ENV{TMP} || die "No tempdir"; $session = new CGI::Session(undef, $cgi, { Directory => $tempdir });
Re: Regarding session path
by Anneq (Vicar) on Apr 22, 2004 at 01:04 UTC

    I ran into in a problem like this and solved it by setting the proper permissions on the tmp directory.

    As well, I use /tmp on Windows and it works. The directory is under my web site root node, for example c:/www/htdocs/tmp.



Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://346923]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-06-29 04:40 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (94 votes). Check out past polls.