Gossamer Forum
Home : General : Perl Programming :

Cookie help

Quote Reply
Cookie help
Hi,

Does anyone know how I might go about setting a cookie for something like this:

1) A visitor comes to your site
2) They visit a certain page
3) They leave your site
4) When they return to your site the following day or following week a message will be shown saying:

"You last visited ???" with ??? being a link to the last part of the site they visited?

Any ideas on how to go about doing this, or even possibly references where I might be able to find info on setting a cookie like this? Thank you.
Quote Reply
Re: Cookie help In reply to
Quote Reply
Re: Cookie help In reply to
#!/usr/bin/perl

use CGI qw/:standard/;
use CGI::Cookie;


$time = scalar localtime;
$ref = $ENV{HTTP_REFERER};

# Create new cookies and send them
$cookie1 = new CGI::Cookie(-name=>'Time',-value=>$time);
$cookie2 = new CGI::Cookie(-name=>'referer',-value=>$ref);

print header(-cookie=>[$cookie1,$cookie2]);


# fetch existing cookies
%cookies = fetch CGI::Cookie;
$time = $cookies{'Time'}->value;
$ref = $cookies{'referer'}->value;

print "Content-type: text/html\n\n";
print "$time - $ref";




Don't take my work for that..........I may have got it totally wrong........



Paul Wilson.
NEW website coming soon...
Quote Reply
Re: Cookie help In reply to
Um...err ok. I figured this out like 8 months ago. Dude, you must be really bored to pull threads from that far back! :~|

Quote Reply
Re: Cookie help In reply to
I was EXTREMELY bored when I posted this.

It was late last night so I thought Id have a look through some old post that had no replies....lol

Paul Wilson.
NEW website coming soon...