YOU CAN NOT FORCE THE BROWSER TO MAKE A REFRESH utilizing HTML. (Only the user can "reload" or "refresh" the page wich means to repeat the request for the document(s) from the server) with all parameteres unchanged utilizing his / her browser. It's a client side action)
You can REDIRECT THE BROWSER to a URL utilzing HTML even if this is the same as the former one.
Why I prenounce that is simply the way the browser requests a page. When a browser requests a document from a webserver that browser will also remit ALL cookies originating from that webservers qualified domain and all those cookies which the browser is additionally allowed to submit to that specific web server. In repsonse the webser will return the requested document AND the new cookies. If a new cookie has the same identifier as one previously written by the same server the old cookie will be overwritten or actualized so to speak.)
So when your script is being executed due to a call for your scripts URI the webserver will hand all received data to your script. When using CGI.pm you have an easy task. Simply write the new cookies before you start delivering content as the cookies are being sent in the document header.
A small example:
#!/usr/bin/perl -wT
use strict;
$|++;
use CGI qw/:standard /;
use CGI::Cookie;
# dont allow that tiny script to crack this server
$CGI::DISABLE_UPLOADS = 1;
# set this to a reasonable high amount preventing server attacks with
+posting hughe files
$CGI::POST_MAX = 15000;
# please identify, somehow
my $usrPc = remote_host();
# if you've been here before, tell me, as whom you identified
my $usrWasLast = (cookie('ID'))? cookie('ID'):'none';
# what kinda browser ?
my $usrAgent = user_agent();
# well, get a cookie, please accept it, and if not, I don't need that
+info from you anyway :-)
my $hiddenInfo = new CGI::Cookie( -name=>'ID',
-value=>$usrPc,
-expires=>'+3M',
-domain=>'little.perlmonk.org'
);
my $referrer = param('ref') if (param('ref'));
# now give the browser what it requested
print header( -charset=>'iso-8859-1',
-cookie=>[$hiddenInfo]
);
print start_html( -dtd=>'-//W3C//DTD HTML 4.01 Transitional//EN',
-lang=> 'en',
-title=> 'yourPageTITLE'
);
print p(($usrWasLast)? "You've been here before using IP: " . $usrWasL
+ast : "I don't know you.");
print p('You have followed a link to this site from' . $referrer) if d
+efined $referrer;
print end_html();
#
1;
Have a nice day
All decision is left to your taste
|