#!/usr/bin/perl use strict; use CGI::Session; use CGI; use DBI; my $driver="Pg"; my $dbname="drfrog"; my $host="127.0.0.1"; my $user="user"; my $password="password"; my $dbh = DBI->connect( "dbi:$driver(PrintError=>1,RaiseError=>1,Tain +t=>1):dbname=$dbname;host=$host", $user, $password ); my $q=CGI->new; my $id=$q->param('id')||undef; print $id."\n"; my $session = new CGI::Session("driver:PostgreSQL", $id, {Handle=>$dbh +}); my $sid = $session->id(); if (!$session->param("my_name")) { print "no param"; } $session->param("my_name",$session->param("my_name")+1 ); my $name = $session->param("my_name"); $session->expire( '+2m'); $session->expire("my_name" => '+1m'); if ($session->param('_SESSION_ETIME')<=$session->param('_SESSION_ATIME +')-$session->param('_SESSION_CTIME')) { print "time has expired\n"; } undef ($session); if ($id != $sid && defined $id) { print "session has expired\n"; } print $sid."\n"; print $name."\n"; $dbh->disconnect();

In reply to CGI::Session expiry code by drfrog

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.