|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have read through many of the cookie related posts in this forum. Seems that cookies should be easy with CGI.pm which I am using. I have two very simple scripts below. The cookie gets set in IE but not in Netscape! Any suggestions or ideas on why this is not working?
cookie.cgi - This one sets the cookie (or should!) #!/usr/local/bin/perl use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; my $cookie = $q->cookie( -NAME => "user", -VALUE => "lane", -EXPIRES => "+12h", -PATH => "/", -DOMAIN => ".lanevance.com", -SECURE => 0); my $location = "http://lanevance.com/index.cgi"; print $q->header(-COOKIE => $cookie, -LOCATION => $location); index.cgi - This one reads the cookie and prints the value #!/usr/local/bin/perl use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; my $user = $q->cookie("user"); print $q->header(); print "Username from the cookie is $user!"; |
|
#2
|
|||
|
|||
|
After some trial and error I have discovered that the following is what is chocking Netscape up:
-DOMAIN => ".lanevance.com", Any ideas why? Without this in the cookie it sets in both NN and IE. I would like to be able to set the domain because I use a shared SSL cert and the login page I will be using should be secure. If I don't have the domain set then the cookie will be set for the web server name not my domain name. Any work-arounds? |
|
#3
|
|||
|
|||
|
Try putting up on site
I converted yours to one cgi as :
Code:
#!c:/perl/bin/perl
use strict;
use CGI;
my $q = new CGI;
# do we have a cookie
my $user = $q->cookie("user");
# If user is set in cookie; clear user and print cookie
if (defined($user)) {
my $cookie = $q->cookie( -name => "user",
-value => "",
-expires => "-1D",
-PATH => "/",
#-DOMAIN => ".lanevance.com",
-SECURE => 0);
print $q->header(-cookie => $cookie);
print "Username from the cookie is $user!<br><br>\n";
print "Debug of Cookie : $cookie ";
exit;
}
# if user is not set in cookie then set and print cookie
if (! defined($user)) {
my $cookie = $q->cookie( -NAME => "user",
-VALUE => "mary",
-EXPIRES => "+12H",
-PATH => "/",
#-DOMAIN => ".lanevance.com",
-SECURE => 0);
print $q->header(-cookie => $cookie);
print "Cookie Set -- Refresh [ Reload or F5 ] to see cookie user<br><br>\n";
print "Debug of Cookie : $cookie";
}
exit;
#----------------------- apologies Munday morning formatting in above code. This code should allow you to keep refreshing and looking to see if user is set in cookie. -- Note Netscape cookies are not stored in "Temporary Internet files" folder but under "program files/netscape/users" folder in cookie.txt. Try posting on your site with your domain and without your domain and see what happens.
__________________
Thanks Foot in Mouth ver 1.2.5 Onion |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > More Cookie Problmes.... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|