my $query = new CGI; my $USER_COOKIE = $query->cookie('LOGGEDIN'); ##### COOKIEDATA FORMAT ##### sid : time : user : user_lang : user_perm my ( $CSID, $CTIMEIN, $USER, $USER_NAME, $USER_LANG, $USER_PERM, ) = split (/\:/, $USER_COOKIE ); ##### DO TIMEOUT STUFF my $now = time(); if((( $now - $CTIMEIN ) < $timeout ) && ($CSID eq "$FORM{'sid'}")) { ##### COOKIEDATA FORMAT ##### sid : time : user : user_name : user_lang : user_perm my $cookie_data = qq¿$CSID:$now:$USER:$USER_NAME:$USER_LANG:$USER_PERM¿; $expires = $now + $timeout ; ##### Set cookie : No need to redirect as session still valid my $user_loggedin = new CGI::Cookie( -name=>'LOGGEDIN', -value=>$cookie_data, -expires=>$expires, ); print "Set-Cookie: $user_loggedin\n"; } else{ ##### Redirect user to login.cgi my $user_loggedin = new CGI::Cookie( -name=>'LOGGEDIN', -value=>'', -expires=>'-1d', ); my $redirect = qq¿$SITE_BASE_URL/login.cgi?timeout=y¿; print $query->redirect( -cookie=>$user_loggedin, -uri=>$redirect, -target=>'_top', ); exit(0); }