...

View Full Version : Reading 3rd party cookies



snogintheloo
03-22-2010, 10:57 PM
I have an interesting situation where I have to read another site's cookie as part of their validation. And I'm not sure of how to go about this.

So far,I have this:

use CGI::Cookie;
my %cookie_values = CGI::Cookie->fetch;
my $name = "theircookiename";
if(exists($cookie_values{'$name'})){
while (($key, $value) = each(%cookie_values)) {
print "$key = $value ";
}
}else{
print qq[No Cookie];
}


Since it only prints "No Cookie", I'm obviously missing something. Any insights would be appreciated.

Frenzie
09-18-2010, 05:00 AM
Hi,

I'm having a similar problem. Did you ever find the solution?

bazz
09-18-2010, 04:01 PM
you have single quotes around '$name'. remove them.

As it is, you are mamking it look for a hash value with the key of $name, instead of its actual variable value. so its looking for $name instead of theircookiename



use CGI::Cookie;
my %cookie_values = CGI::Cookie->fetch;
my $name = "theircookiename";
if(exists($cookie_values{$name})){
while (($key, $value) = each(%cookie_values)) {
print "$key = $value ";
}
}else{
print qq[No Cookie];
}


You might find it helpful to dump out the %cookie like this:



use Data::Dumper;

print Dumper \%cookie;

Frenzie
09-18-2010, 08:11 PM
use CGI::Cookie;
my %cookie_values = CGI::Cookie->fetch;
my $name = "theircookiename";
if(exists($cookie_values{$name})){
while (($key, $value) = each(%cookie_values)) {
print "$key = $value ";
}
}else{
print qq[No Cookie];
}



I just get a blank page.

bazz
09-18-2010, 10:49 PM
sorry. try this



use Data::Dumper;

print Dumper \%cookie_values;


You should at least see


$VAR1 = {};


If that is what you see, then the hash cookie_values is not being populated which tends to make me think that there is something worng in the initial code


use CGI::Cookie;
my %cookie_values = CGI::Cookie->fetch;


I have not used that module so I cannot help with it much.


You could try



my $cookie_values = CGI::Cookie->fetch;

print Dumper \$cookie_values;

and see what that outputs.


bazz

Frenzie
09-19-2010, 12:41 PM
Thanks for the suggestions but I tried, got nothing and finally gave up. I found HTTP Cookie Library (http://www.scriptarchive.com/cookielib.html) which I will try.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum