Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cookie read problem

Status
Not open for further replies.

chance42

Technical User
Aug 5, 2004
22
US
Hello all,

I have created a tasklist for my staff at work.
I wrote and tested it on my PC at home running
Linux 2.4.20 with Apache 2.0.45 and Perl 5.8.0.

The user first hits a login page where they select
their shift and enter their name,
that information is set in a cookie for later use.
The actual page with the tasks will check for the cookie
and if it does not find it, the user is redirected to the
login page.

Now, it worked just fine at home, but when I put it on our
server at work, Solaris server on and UltraSparc 5 running
SunOS 5.8 Apache 1.3.26 and Perl 5.8.3 it will create the cookie but will fail to recognize it's existance.


I have tried it at home using Apache 1.3.27
and that works as well.

Here is the code from the login.cgi file:

#!/usr/bin/perl -w
use strict;
use warnings;
use CGI qw:)standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $q = new CGI;

my $username = param ('username');
my $shift = param ('shift');

# Register the cookies
my $cookie1 = $q->cookie(-name=>'TASKLIST_LOGIN',
-value=>"$username:$shift",
-expires=>'+12h');

print $q->header(-cookie=>[$cookie1]);



And here is the relevant part of the tasks script:

#!/usr/bin/perl -w
use strict;
use CGI qw:)standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $q = new CGI;

# Check user is logged in and get user name and shift
if(defined $q->cookie('TASKLIST_LOGIN')) {
my $cookie = $q->cookie('TASKLIST_LOGIN');
(my $username, my $SHIFT) = split(/:/, $cookie);


We are running XP with IE 6 here at work and you can
go into Tools->Internet Options->Settings->View Files
and see and read the cookie so I know it's getting created.

Anyone have any ideas?
I am lost..
 
Try changing your defined statements to the following. I've used this method in the past (although for the life of me, I cannot find the documentation that I read stating to do it this way) and it works flawlessly.

Code:
if(defined $q->cookie( -name => 'TASKLIST_LOGIN' )){
    my $cookie = $q->cookie ( -name => 'TASKLIST_LOGIN');
. . .

- Rieekan
 
mlewelling
you write the code light blue on dark blue
your probl is 'light'
to solve it
write the code 'dark' blue on dark blue
:)
 
Thanks Rieekan, no suck luck, the code works perfectly
on my home computer, even accessed from work, it just does
not want to function at work.

I did make the changes you sugested, but there was no change. The cookie is still created but the code thinks
that there is no cookie.

?! :-( !?
 
This is very strange. What other troubleshooting have you done? Have you tried other browsers at work? What version of CGI.pm (though unlikely, maybe it's an older buggy version)? Did you make sure you don't have some software or proxy that's blocking the cookie from being sent to the web server?

 
Thanks philote!!!

I was starting to go wiggy.

It turns out we have some proxy crap in place to keep
poeple from downloading stuff to the server or surfing
through the server...

Now the hard part is to see if I can get that opened up.

Thanks everyone!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top