Forum Moderators: coopster & phranque

Message Too Old, No Replies

Set Cookie & Redirect doesn't work in Mac IE

Page doesn't go anywhere after clicking submit

         

MichaelBluejay

10:44 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This works fine in MSIE6 and Safari, but when I click Submit in MacIE the status bar shows that a new page is loading, and then stops, but no page ever loads. I'm still looking at my form.

Here's my code:


#!/usr/bin/perl -w

use CGI ':standard';

if (param('code') eq 'booboo' ) {

print "Set-Cookie: 'name'='booboo'; path='\'; domain='example.com'; expires='+365d';\n";
print "Location: [example.com...]

}
else { print"Location: [example.com...] }

While I'm at it, I'm a little hazy on loading CGI modules. Some sample code tells me to do <use CGI ':standard';> while another says <use CGI qw(:cgi);> and yet another says <use CGI.pm>. Can I just call all of them (one on each line), or do they interfere with each other?

Thankie-doodle, -MBJ-

timster

12:53 pm on Jun 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



While I'm at it, I'm a little hazy on loading CGI modules. Some sample code tells me to do <use CGI ':standard';> while another says <use CGI qw(:cgi);> and yet another says <use CGI.pm>. Can I just call all of them (one on each line), or do they interfere with each other?

I'll ignore your harder, main question and just talk about "use CGI."

This falls under the heading "There's More Than One Way To Do It." Just one of these should be just fine. I usually just do "use CGI;" and move on. If that ever fails, just go back to whatever the script used originally.

(Bump. Can anyone help with the HTTP Headers issue?)

VectorJ

3:57 pm on Jun 22, 2004 (gmt 0)

10+ Year Member



There are a couple of errors in the script itself (no $ before the params hash, not putting the key/values into %params before trying to use them), but even so, it should redirect. The Location header looks correct to me. Check that there isn't a problem in the destination page. If you are actually reloading the same page when you find that there is no cookie set, then because of the errors in the rest of the script, you'd be putting the browser into an infinite loop.

Also, you may need to put a "." before the domain name in the Set-Cookie string. As I recall, IE/Win can deal with it incorrectly formatted, but other browsers, like netscape, can't.

MichaelBluejay

9:56 pm on Jun 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm afraid I'm not having much luck. I changed the set cookie & redirect code to this:

print redirect( -URL => "http://example.com/page1.html",
-COOKIE => $cookie);

The cookie gets set properly but the page doesn't redirect. Problem exists only in MacIE5, works fine in Safari and MSIE6. The pages being redirected to are different from the page that the form is on which calls the script.

Darn Mac IE!