CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Cookie problem-www.site.com & site.com screws them

 



NeilF
Deleted

Apr 4, 2001, 6:37 AM

Post #1 of 2 (189 views)
Cookie problem-www.site.com & site.com screws them Can't Post

I have a CGI script (forum) which remembers a users username and password by storing 2 cookies.

I've noticed though if I logon to my site without using the WWW (eg: just site.com instead of www.site.com) it seems that when I then go back to using the normal URL (eg: www.site.com) BOTH sets of cookies are returned. Ie: I get in my cookie two logon values and two password values. eg: user=A;user=A;pass=B;pass=B

If I return back to the WWW less URL (eg: site.com) only one set is returned. eg: user=A;pass=B

This must obviously be something to do with the cookie setting. Maybe something to do with the DOMAIN value?

Any ideas?



Jasmine
Administrator / Moderator

Apr 4, 2001, 11:12 AM

Post #2 of 2 (182 views)
Re: Cookie problem-www.site.com & site.com screws them [In reply to] Can't Post

Set the cookie domain to .yourdomain.com (note the leading dot). If the cookie domain attribute is omitted, it will only set the cookie to the server that created it.


Code
use CGI qw /:standard/; 

my $in = CGI->new();

my $username = $in->param('username');

my $cookie = cookie(
-name => 'username',
-value => $username,
-domain => '.yourdomain.com',
);

print header( -cookie => $cookie );


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives