Click to See Complete Forum and Search --> : Internet Explorer aint listening!


chrisbot
11-28-2005, 05:53 PM
Have another prob now. Have been working on an online application. This is the prob.

Html file submits 3 variables to pl cgi. There variables are used to generate a page specific to the variables and returns this to the browser.

On that page are a couple of paypal buttons which direct the browser to paypal. What I want is for the browser to return to the page it left, only when this happens it has lost the variables so will not render.

To sort this I made the script write the variables as cookies, and then pick them up again, so as you can re-enter the page. This works seemlessly on Safari, but just tested it on IE and bugger me it wont work. What is up with Microsoft????

#!/usr/bin/perl
if ($ENV{'HTTP_COOKIE'})
{ @cookies=split(/; /,$ENV{'HTTP_COOKIE'}) };
foreach $item(@cookies)
{ ($key,$content) = split(/=/,$item,2);
$fields{$key}=$content;
}

read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{
($key,$content)=split(/=/,$item,2);
$content=~tr/+/ /;
$content=~s/%(..)/pack("c",hex($1))/ge;
$fields{$key}=$content;
}


# SAVE VARIABLES IN COOKIES

print "Set-Cookie:course = $fields{course} ;
expires = Thu, 01-Dec-2006 00:00:00 GMT\n";
print "Set-Cookie:method = $fields{method} ;
expires = Thu, 01-Dec-2006 00:00:00 GMT\n";
print "Set-Cookie:currency = $fields{currency};
expires = Thu, 01-Dec-2006 00:00:00 GMT\n";

# VARIABLES

$d = $fields{course};
$m = $fields{method};
$c = $fields{currency};

this is my script, what can I do to get IE to behave???

Chris

FromU2ME
12-08-2005, 01:16 PM
Well, hm, IE shouldn't trouble with your cookies - split up the code and try them apart to find out the problem (common script debugging :) ).

Did you try the script in any other browser? Is it on Mac or PC?

gozarca2
12-11-2005, 12:28 PM
I use this to set my cookies (in html, javascript):
var cookieVar =
document.new_form.Coordinator.value + "|" +
document.new_form.coordPhone.value + "|" +
document.new_form.coordEmail.value + "|" +
document.new_form.TisCode.value + "|";
setCookie(cookieName, cookieVar);

and to draw themout:
function unstringIt(stringValue) // Get the cookie info already stored
{
e=stringValue.indexOf("|");
document.new_form.Coordinator.value = stringValue.substring(0,e++);
i=e;
e=stringValue.indexOf("|",i);
document.new_form.coordPhone.value = stringValue.substring(i,e++);
i=e;

...
function checkCookie()
{
var search = cookieName + "=";
if (document.cookie.length > 0) // any cookies at all?
{
offset = document.cookie.indexOf(search)
if (offset != -1) // is this name there?
{
offset += search.length // set index of beginning of value
end = document.cookie.indexOf(";", offset); // set index of end of value
if (end == -1)
{
end = document.cookie.length
} // end of end if
unstringIt(unescape(document.cookie.substring(offset,end)));
} // end of offset if
} // end of length if
document.new_form.atmPass.select();
document.new_form.atmPass.focus();

} // end of function checkCookie
...
<BODY bgcolor=#FFFFFF onload="checkCookie()" >

fireartist
12-12-2005, 04:31 AM
That hurts my eyes!
Try using the CGI (http://search.cpan.org/~lds/CGI.pm-3.15/CGI.pm#HTTP_COOKIES) module to read and write your cookies - it's been tested with most browsers - and works.

aj_nsc
12-20-2005, 09:22 AM
Perhaps a less secure way (but one thats a million times easier) to solve your problem is to just write a few hidden forms with their values being the variables in your CGI-generated page.

There are of others way to do this such as store the variables in some randomly generated file in your cgi-bin while they're still needed and then dump them after. That's a bit more secure than the hidden forms method.

winged1
12-20-2005, 11:14 AM
those values are on the original page anyway, so why not just add a couple of hidden form fields to pass the info along.

Scriptage
12-21-2005, 04:37 AM
CGI::Session all the way. It's a beautiful little module.