Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 30th, 2001, 11:38 AM
lanevance lanevance is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: South Florida
Posts: 0 lanevance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation More Cookie Problmes....

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!";

Reply With Quote
  #2  
Old June 30th, 2001, 01:31 PM
lanevance lanevance is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: South Florida
Posts: 0 lanevance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #3  
Old July 2nd, 2001, 01:25 PM
footinmouth footinmouth is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: North Vancouver, BC, Canada
Posts: 44 footinmouth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > More Cookie Problmes....


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway