Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading 3rd party cookies

    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.

  • #2
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

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

  • #3
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    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

    Code:
    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:

    Code:
    use Data::Dumper;
    
    print Dumper \%cookie;
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #4
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bazz View Post
    Code:
    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.

  • #5
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    sorry. try this

    Code:
    use Data::Dumper;
    
    print Dumper \%cookie_values;
    You should at least see
    Code:
    $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
    Code:
    use CGI::Cookie;
    my %cookie_values = CGI::Cookie->fetch;
    I have not used that module so I cannot help with it much.

    Edit:
    You could try

    Code:
    my $cookie_values = CGI::Cookie->fetch;
    
    print Dumper \$cookie_values;
    and see what that outputs.


    bazz
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link

  • #6
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the suggestions but I tried, got nothing and finally gave up. I found HTTP Cookie Library which I will try.
    Last edited by Frenzie; 09-19-2010 at 08:39 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •