Hi, If you could help me I would appreciate it. The following code below creates a session and cookie. The problem is it never initializes the session again, it always creates a new session and cookie every time. Do you see anything I'm missing?
#!/opt/bin/perl #use strict; use CGI::Carp; use CGI; use File::Spec; use CGI::Session; use Date::Manip; #use CGI::Session::DB_File; print "Content-type: text/html\n\n"; my $cgi = new CGI(); my $session = new CGI::Session(undef, $cgi, {Directory=>File::Spec->tmpdir }); my $sweet = $cgi->cookie($session->name); if ($sweet) { print "cookie exists $sweet<BR>"; my $ipa = $session->param("_SESSION_REMOTE_ADDR"); my $i = $session->param("NVISITS") || 0; #If Statement I can use f +or other values $session->param("NVISITS", ++$i); my $current=&ParseDate("today"); my $d = $session->param("Dateid") || $current; #If Statement I can use for other values $session->param("Dateid", "$current"); $session->expire('+1m'); print $cgi->start_html(-title=>"Session"), $cgi->h1("Session Information"), #$cgi->h1("Hello World from CGI::Session/$CGI::Session::VERSION"), $cgi->p("This is CGI::Session $CGI::Session::VERSION"), $cgi->p("Your session id is <strong>" . $session->id . "</strong>"); print $cgi->div("You visited this page $i times so far, right? Date $d IP Address: $ipa $sweet<BR>"); #print $cgi->div("You visited this page $i times so far, right? Date $d IP Address: $ipa cookie session: $sweet<BR>"); #print $cgi->p("Cookie Session: $getcookie"); #print $cgi->end_html(); }else{ print "New cookie set<BR>"; #Building a cookie to be sent to user my $cookie = $cgi->cookie(-name=>$session->name, -value=>$session->id, -expires=>'+1m'); # Setting cookie in the Browser: print $cgi->header(-cookie=>$cookie); #print $cgi->header(-type=>'text/html', -cookie=>$cookie); #print $cgi->header(-cookie=>$cookie); my $ipa = $session->param("_SESSION_REMOTE_ADDR"); my $i = $session->param("NVISITS") || 0; #If Statement I can use f +or other values $session->param("NVISITS", ++$i); my $current=&ParseDate("today"); my $d = $session->param("Dateid") || $current; #If Statement I ca +n use for other values $session->param("Dateid", "$current"); $session->expire('+1m'); } exit;
-- Kory Wheatley Academic Computing Analyst Sr. Phone 282-3874 ######################################### Everything must point to him.

In reply to Perl Cgi Session cookie initializing by koryw

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.