ramesh_ps1 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am new to Perl CGI and I am having problem on with refreshing page.

I am using

<meta HTTP-EQUIV='REFRESH' content='10;url=/user/statusdisplay.cgi'> to refresh the page once every 10 seconds.

But on refreshing I am loosing few environment vareables like,

$ENV{CONTENT_LENGTH} is brcoming "0" and
$ENV{HTTP_REFERER} is not available.

I do have few checks in the begining of the script to determine the calling page and since $ENV{HTTP_REFERER} is not available on refresh some of my conditions fail and the application doesnot work properly.

Is there any alternate way to retain these values even on refresh?
  • Comment on Perl CGI : loosing values of $ENV{HTTP_REFERER} and $ENV{CONTENT_LENGTH} on refresh

Replies are listed 'Best First'.
Re: Perl CGI : loosing values of $ENV{HTTP_REFERER} and $ENV{CONTENT_LENGTH} on refresh
by Corion (Patriarch) on Sep 21, 2007 at 08:44 UTC

    This is not really a "refresh" in the sense of pressing the "reload" button in your browser. The META tag issues a new GET request to /user/statusdisplay.cgi. If you want to remember values across the page loads, encode them into the target URL:

    use strict; use CGI qw(:standard); use URI::Escape; my $referrer = escapeHTML(uri_escape($ENV{REFERRER})); print <<HTML <meta HTTP-EQUIV='REFRESH' content='10;url=/user/statusdisplay.cgi?ref +=$referrer'> HTML

    The Content-Length will be 0 because you don't get the data POSTed anymore. If you want to keep the data POSTed to your first script, you will need to store it locally and pass a hint to your refresh page.