use strict; use warnings; use DBI; use CGI; use CGI::Carp qw(fatalsToBrowser); my $cgi = CGI->new(); my $sid = $cgi->cookie('login'); my $login = 'http://localhost/cgi-bin/login.pl'; if ( ! $sid ){ # exit and return to login.pl! we have no cookies print $cgi->redirect($login); } #start using the page! we have cookies print $cgi->header(); # etc