-- Kory Wheatley Academic Computing Analyst Sr. Phone 282-3874 ######################################### Everything must point to him.#!/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;
In reply to Perl Cgi Session cookie initializing by koryw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |