Programming :  Student Freelance Forum For Work Experience Builders' (CertificationPoint) The fastest message board... ever.
 
PERL-MOD PERL Help
Posted by: adcertpoint (Moderator)
Date: April 29, 2020 04:40PM

META: should be annotated at some point.

use strict;
use DBI;
use Apache:confused smileyession:grinning smileyBI;
use CGI;

# [...]

# Initiate a session ID
my $session = ();
my $opts = { autocommit => 0,
lifetime => 3600 }; # 3600 is one hour

# Read in the cookie if this is an old session
my $r = Apache->request;
my $no_cookie = '';
my $cookie = $r->header_in('Cookie');
{
# eliminate logging from Apache:confused smileyession:grinning smileyBI's use of `warn'
local $^W = 0;

if (defined($cookie) && $cookie ne '') {
$cookie =~ s/SESSION_ID=(\w*)/$1/;
$session = Apache:confused smileyession:grinning smileyBI->open($cookie, $opts);
$no_cookie = 'Y' unless defined($session);
}
# Could have been obsolete - get a new one
$session = Apache:confused smileyession:grinning smileyBI->new($opts) unless defined($session);
}

# Might be a new session, so let's give them a cookie back
if (! defined($cookie) || $no_cookie) {
local $^W = 0;

my $session_cookie = "SESSION_ID=$session->{'_ID'}";
$r->header_out("Set-Cookie" => $session_cookie);
}



Edited 1 time(s). Last edit at 07/22/2021 06:28PM by adcertpoint.

Options: ReplyQuote


Sorry, only registered users may post in this forum.
This forum powered by Phorum.