#!/usr/bin/perl use strict; use warnings; use CGI qw(:cgi-lib); use Date::Calc qw(:all); use CGI::Carp qw(fatalsToBrowser); use CGI qw/:standard/; use DBI; use CGI::Cookie; $current_time = time(); my $ck1 = new CGI::Cookie( "-name" => "time","-value" => "$current_time" ); print "Set-Cookie: $ck1\n"; print "Content-Type: text/html\n\n"; my %cookies = fetch CGI::Cookie; $cookie_time = $cookies{time}->value; if ($current_time - $cookie_time > 160) { print "Location: ../login_index.html\n\n\n"; exit; } # print cookie(s) before redirecting, for testing only foreach (keys %cookies) { print cookies here.... }