I am trying to make a script that check for a cookie and redirects the user to one page if it does not exists. If it exists I don't want the script to do anything so the reset of the HTML page that calls it (via SSI) loads. Problem is I can't figure out how to make the redirect happen. Can anyone help me? The code I have is:
#!perl -w
use strict;
use CGI q~:standard~;
use DBI;
use CGI::Cookie;
use CGI::Carp q~fatalsToBrowser~;
my(%Cookies, @Values, $Username, $Password, $Error, $DBH, $STH);
print "Content-type: text/html\n\n";
%Cookies = fetch CGI::Cookie;
if ($Cookies{'FFAdmin0229'}) {
@Values = $Cookies{'FFAdmin0229'} -> value;
$Username = $Values[0];
$Password = $Values[1];
} else {
print redirect(-location => 'http://admin.ffinfo.com/');
}
The redirect code works on the login check script but when I use it here it just prints "Status: 302 Found Location: http://admin.ffinfo.com/"
The HTML code I am using is this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/
+/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#exec cgi="/ssi/checkcookie.pl"-->
<html xmlns="http://www.w3.org/1999/xhtml">
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.