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

This works fine when I test it on my site (which is hosted on a Linux box), but doesn't seems to work properly when testing it on my comp (running WinXP).

I'm trying to create a sessions with the following code:
my $var = 'test'; my $session = new CGI::Session("driver:File", undef, {Directory=>" +/tmp"}); $session->param("display_name", $display_name); $session->param("access_level", $access_level); $session->param("site_name", $site_name); $session->param("user_id", $user_id); $session->param("signature", $signature); $session->param('+18h'); my $cookie = $foo->cookie($var => $session->id); print $foo->header( -cookie=>$cookie );
As you can see, I want to use the contents of a variable as the name of the variable that will store the sessionID in the cookie.
And then retrieve the session's info with the following code:
my $sid = $foo->param('test'); my $session = new CGI::Session(undef, $sid, {Directory=>'/tmp'}); my $access_level = $session->param("access_level") || 0; my $display_name = $session->param("display_name") || ""; my $user_id = $session->param("user_id") || 0; print "Sid: $sid<BR> Session: $session<BR> Access: $access_level<BR> Name: $display_name<BR> User ID: $user_id<BR>\n";
With the print statement, I get:
Sid: bab864bfd5e46898b2252e19cffdf038 Session: CGI::Session::File=HASH(0x1bc0680) Access: 0 Name: User ID: 0
When I do the same test on my website (exact same script) it works fine. The appropriate access, name, and User ID are printed. I'm completely stumped to why this isn't working on my machine.

Thx for any help you might be able to offer,
Steny

Replies are listed 'Best First'.
Re: CGI::Session - Problems creating session...
by cees (Curate) on May 02, 2003 at 04:17 UTC

    Do you have a /tmp directory on you WinXP box? I am guessing that you will need to use something like C:\temp instead.

      a /tmp directory exists under my cgi-bin directory.
      so, the path to the tmp directory is:
      c:\apache\cgi-bin\tmp
        I don't have a Windows box to test this on, but based on the docs for CGI::Session::File, I believe cees was right in that /tmp doesn't exist on a Windows machine; {Directory => '/path'} is looking for a filesystem directory, not a subdirectory on your webserver (as you described).

        Have you tried changing it to {Directory => 'C:\temp'} or {Directory => 'c:\apache\cgi-bin\tmp'} instead?
        ;)
        use Cwd; use Config; chdir $Config{archlib}; print cwd,$/; chdir 'Pod'; print cwd,$/; chdir '..'; print cwd,$/; chdir '/Pod' or warn "eek $!"; print cwd,$/; chdir '/'; print cwd,$/; __END__ C:/Perl/lib C:/Perl/lib/Pod C:/Perl/lib eek No such file or directory at - line 13. C:/Perl/lib C:/
        Absolute paths begin with a path separator (or drivename, depending on os, use File::Spec if you like portability -- see `perldoc perlport'), relative paths begin with a directory name (like ./foo)


        MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
        I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
        ** The Third rule of perl club is a statement of fact: pod is sexy.