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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl & Cookies & Internet Explorer

Status
Not open for further replies.

lezhik

Programmer
Joined
Oct 21, 2003
Messages
20
Location
RU
Couldn't get cookies back from IE. tried to send them in two ways:
1)
print "Set-cookie: CFISESSID=$sid; path=/pepsite\n";
print "Content-type: text/html\n\n";
2)
$cgi=new CGI;
$session = new CGI::Session(undef, $sid, {Directory => '/tmp'});
$cookie = $cgi->cookie(-name => 'CGISESSID', -value => $sid, -path=>'/pepsite/cgi-bin');
print $cgi->header(-type=>'text/html',-cookie => $cookie);
getting cookie with:
$sid = $cgi->cookie('CGISESSID') || undef;

both variants works correctly for opera and netscape, but not for IE, what is the problem?
 
I have to ask the obvious: is IE set to accept cookies?

There's always a better way. The fun is trying to find it!
 
It was the first thing that I have checked, IE accepts cookies from other sites, no secure restrictions for this site.
Of cause it posssible, to pass session id via URL, but I want to implement normal solution with cookies.
 
Some questions:
1) How do you know the cookies are not being set?
2) Have you tried a different browser?
3) Does your script print anything before the header?

 
Try with this code:

print "P3P: CP=\"CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE\"\n";
print "Set-Cookie: CFISESSID=$sid; domain=.YOURDOMAIN.COM; path=/\n";
print "Content-type: text/html\n\n";

Change .YOURDOMAIN.COM to your domain, e.g. .something.com

See if this works and then work from that up.
 
Just some observations...

IMHO, I wouldn't use $cgi for variable name - too much a risk for future releases as it may be, or could become a reserved word.

What value are you giving to $sid here: print "Set-cookie: CFISESSID=$sid; path=/pepsite\n";

or here: $session = new CGI::Session(undef, $sid, {Directory => '/tmp'});

There's always a better way. The fun is trying to find it!
 
As i investigate it is not a script problem, but problem is between Apache and IE, that is the result of telnet on 80 port:

Trying 127.0.0.1...
Connected to localhost.

Escape character is '^]'.

HTTP/1.1 200 OK
Date: Tue, 13 Jul 2004 08:46:08 GMT
Server: Apache/2.0.50 (Unix) mod_jk2/2.0.4-dev
Set-cookie: CGISESSID=f2275f7a11ea1dbf01bbc271fdfaf1e3
Connection: close
Content-Type: text/html; charset=ISO-8859-1

<html>...</html>

It seems to me that IE just ignore evrything before the "connection: close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top