in reply to Re: Re: cookie retrieval problem
in thread cookie retrieval problem

Ah, that problem again. <grin>

Well, I can think of basically two approaches. Either you provide a special, different cookie value to each user, either semi-randomly assigned or via a login page, and you can then track any visitor to your site.

Or, you don't set cookies for everybody, but only for yourself. You can have a special page, which you use to enter the site, but which nobody else knows of. All it has to do is set a cookie, and redirect you to the normal entrance. Every other page only has to read the cookie value. The following code forms the entrance page for the latter approach:

#!/usr/bin/perl -w use CGI qw(:standard); my $cookie_out = cookie(-name=>'test', -value=>'Nikolas was here!'); print redirect(-cookie=>$cookie_out, -uri => "index.html");
I'm assuming "index.html" is the normal index page to your site's directory.

Now if you change the other script so it only reads the cookie (so drop the assignment to $cookie_out), you can visit the above script first, then go to the other script, possibly even by typing in the URL manually, and you'll see the cookie value as set here.

Replies are listed 'Best First'.
Re: Re: Re: Re: cookie retrieval problem
by Nik (Initiate) on Feb 29, 2004 at 23:40 UTC
    Thanks guys but i have decided that the best way for my script to identify me is even simpler that using cookies.... here it is....

    if ($host =~ /thes530-.*?\.otenet\.gr|millennium-.*?\.ccf\.auth\.gr/)
    Although my ip from the two providers i use is dynamic this solution works just fine for me :)

    The cookies solution can alsobe done but it wouldn't be as quick and short as this one :)
      It'll work for you, and for thousands of other people using the same ISP. I don't think you really want to discard them, as they're among your more likely visitors.
      A reply falls below the community's threshold of quality. You may see it by logging in.