Hello there,

I have been trying to implement an idea of an account into AWStats. For this I want to use session so we can store a name and url in a session when a user logs on.

Could my problems be down to using IIS? Also "{Directory=>'/tmp'}", I have tried creating this in the website root and the drive root but nothing ever gets written with my example - any ideas?

I have tried many variations of scripts with no luck. I just cant maintain states across pages. My latest attempt is below...
Page one... use CGI::Session; use CGI; my $cgi = new CGI; my $session = new CGI::Session(undef, $cgi, {Directory=>'/tmp'}); $cookie = $cgi->cookie(CGISESSID => $session->id ); print $cgi->header(-cookie=>$cookie); $session->param('f_name', 'Sherzod'); print '<a href="session2.pl">Page 2</a>';


Page 2... use strict; use CGI::Session; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use CGI; my $cgi = new CGI; my $session = new CGI::Session(undef, $cgi, {Directory=>'/tmp'}); my $cookie = $cgi->cookie(CGISESSID => $session->id ); print $cgi->header(-cookie=>$cookie); my $name = $session->param("l_name"); print $name; I found one example on the web which isnt working and comes up with "Y +ou have not logged in". Page one... use CGI; use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; use CGI::Session ( '-ip_match' ); $q = new CGI; $usr = $q->param('usr'); $pwd = $q->param('pwd'); if($usr ne '') { # process the form if($usr eq "demo" and $pwd eq "demo") { $session = new CGI::Session(); print $session->header(-location=>'index.pl'); } else { print $q->header(-type=>"text/html",-location=>"login.pl"); } } elsif($q->param('action') eq 'logout') { $session = CGI::Session->load() or die CGI::Session->errstr; $session->delete(); print $session->header(-location=>'login.pl'); } else { print $q->header; print <<HTML <form method="post"> Username: <input type="text" name="usr"> Password: <input type="password" name="pwd"> <input type="submit"> </form> HTML }


Page 2...
use CGI; use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; use CGI::Session ( '-ip_match' ); $session = CGI::Session->load(); $q = new CGI; if($session->is_expired) { print $q->header(-cache_control=>"no-cache, no-store, must-revalid +ate"); print "Your has session expired. Please login again."; print "<br/><a href='login.pl>Login</a>"; } elsif($session->is_empty) { print $q->header(-cache_control=>"no-cache, no-store, must-revalid +ate"); print "You have not logged in"; } else { print $q->header(-cache_control=>"no-cache, no-store, must-revalid +ate"); print "<h2>Welcome"; print "<a href='login.pl?action=logout'>Logout"; }

In reply to Storing Session Across Pages - IIS To Blame? by SketchySteve

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.