Click to See Complete Forum and Search --> : New boy needs a hand


twonames
12-19-2002, 08:50 AM
I'm an aged mainframe programmer struggling with cookies on a web server with Microsoft Frontpage extentions.

I have no choice over the architecture or tools available to me. I'm trying to do something and I'm not winning.

I have used a script called "only popup once" on a web page with no problems and I'm trying to adapt it. I want the popup window to be a 'feedback form' and when the form is completed it goes to a "thank you" page. I want the Thank you page to update the cookie tested by the main page.

I built the individual pages and visited them manually and all was well - going to 'main' page caused survey to pop up. Visit 'thank you' page manually updated the cookie and subsequent visits to 'main' did not pop the survey up.

The problem is that the main page creates a cookie called
"cookie:username@intranet...../" but when I get to the thank you page via the feedback form, a different cookie gets created "cookie:username@intranet...../_vit_bin/shtml.dll/"

So the question is how do I make the script in the thank you page reference and update the cookie created in the main page?

Thanks.

khalidali63
12-19-2002, 09:07 AM
At the thank you page you should be looking for the coockie signature that was created in the welcome page?

make sense?

:-)

twonames
12-19-2002, 09:11 AM
Nope!

Do you need more info to make sense of my question? Would it help if I post the scripts I'm using? (it might give you a bit of a laugh at least!)

khalidali63
12-19-2002, 09:13 AM
how about giving me the links of the pages,I'll visit them both and see whats going on

twonames
12-19-2002, 09:15 AM
Unfortunately, they are intranet pages and not viewable from the outside world

khalidali63
12-19-2002, 09:42 AM
well in that case you may have to post both your code snippets , the one on welcome page as well as the one on thank you page

twonames
12-19-2002, 09:53 AM
I'm grateful for your help. It's very frustrating trying to do something with no training and no experts in-house to call on.

I've got three pages..
Main, Survey and Survey_done

I'm using the script from javascript.internet.com

From what I can see, a cookie is named after the url of the folder owning the page creating it
eg intranet.bankone.net/mysite/

that url is where all my pages live. But because the Survey_done page is being invoked by some frontpage extention, its cookie goes under the name intranet.bankone.net/mysite/_vit_bin/shtml.dll/

Here's the code from main.htm


<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var expDays = 360; // number of days the cookie should last

var spage = "survey.html";
var windowprops = "width=700,height=650,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes";

function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}


function SetCookie (name, value)
{
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}


function DeleteCookie (name)
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


function amt()
{
var count = GetCookie('survey')
if(count == null)
{
SetCookie('survey','1')
return 1
}
else
{
var newcount = parseInt(count) + 1;
DeleteCookie('survey')
SetCookie('survey',newcount,exp)
return count
}
}


function getCookieVal(offset)
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}


function checkCount()
{
var count = GetCookie('survey');
if (count == null) {count=1;}
if (count < 99)
{
count++;
SetCookie('survey', count, exp);

window.open(spage, "", windowprops);

}
else
{
count++;
SetCookie('survey', count, exp);
}
}
// End -->
</script>

#############################

and the body tag has onLoad="checkCount()"



Now here's the code from Survey_done.html



<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var expDays = 360; // number of days the cookie should last

function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}


function SetCookie (name, value)
{
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}


//function DeleteCookie (name)
// {
// var exp = new Date();
// exp.setTime (exp.getTime() - 1);
// var cval = GetCookie (name);
// document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
// }


var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


//function amt()
// {
// var count = GetCookie('survey')
// if(count == null)
// {
// SetCookie('survey','1')
// return 1
// }
// else
// {
// var newcount = parseInt(count) + 1;
// DeleteCookie('survey')
// SetCookie('survey',newcount,exp)
// return count
// }
// }


function getCookieVal(offset)
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}


function killSurvey()
{
var count = GetCookie('survey');
if (count == null) {count=100;}
if (count < 99)
{
count=100;
SetCookie('survey', count, exp);
}
else
{
count=100;
SetCookie('survey', count, exp);
}
}
// End -->
</script>


###############################

Body tag onLoad="killSurvey()"

khalidali63
12-19-2002, 11:08 AM
Is there sometyhong missing?
becuase when I ran the scripts,main.html and Survey_don.html
both read the same cookie hence there must not be a roblem ( I hope)

Does survey page do any thing with cookies?

Khalid

twonames
12-19-2002, 11:17 AM
Yes, as I said, If I visit Main and Survey_done directly they both update the same cookie.

The problem is that when you hit the "submit" button on the survey page, the microsofr frontpage extensions do their stuff and so the url of the survey done page is different and so a different cookie is referenced.

url of main page = http://intranet.bankone.net/mysite/main.html

url of survey_done page is
http://intranet.bankone.net/mysite/survey_done.html

Those two pages reference the same cookie.

BUT.....

we get sent to the survey_done page by some frontpage extensions so the url that the browser displays for the survey_done page is......
http://intranet.bankone.net/mysite/_vit_bin/shtml.dll/ survey_done.html

which results in a different cookie being referenced.

khalidali63
12-19-2002, 11:32 AM
paste the survey forms code here if its possible..

twonames
12-20-2002, 04:31 AM
OK Here's the form part of the page. The basic problem is that I need to be able to reference a cookie named http://web.com/folder/ from a page which lives in http://web.com/folder/subfolder/subfolder/




<FORM METHOD="POST" action="--WEBBOT-SELF--" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1">
<!--webbot bot="SaveResults" startspan U-File="formrslt.txt" S-Format="TEXT/TSV"
S-Label-Fields="TRUE" B-Reverse-Chronology="FALSE"
S-Builtin-Fields="REMOTE_NAME REMOTE_USER HTTP_USER_AGENT"
U-Confirmation-Url="survey_done.html" --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--webbot
bot="SaveResults" endspan --><P>
<font face="Arial">
Please provide the following contact information:</font></P>
<BLOCKQUOTE>
<TABLE>
<TR>
<TD ALIGN="right">
<EM><font face="Arial">Name</font></EM></TD>
<TD>
<!--webbot bot="Validation" B-Value-Required="TRUE" -->
<INPUT TYPE=TEXT NAME="Contact_FullName" SIZE=35>
</TD>
</TR>
<TR>
<TD ALIGN="right">
<EM><font face="Arial">E-mail</font></EM></TD>
<TD>
<!--webbot bot="Validation" B-Value-Required="TRUE" -->
<INPUT TYPE=TEXT NAME="Contact_Email" SIZE=25>
</TD>
</TR>
<TR>
<TD ALIGN="right">
<em><font face="Arial">Country</font></em></TD>
<TD>
<!--webbot bot="Validation" B-Value-Required="TRUE" -->
<INPUT TYPE=TEXT NAME="Country" SIZE=35>
</TD>
</TR>
</TABLE>
</BLOCKQUOTE>
<P>
<font face="Arial">
How often do you use FIRSTWeb?</font></P>
<BLOCKQUOTE>
<P>
<!--webbot bot="Validation" B-Disallow-First-Item="TRUE" -->
<SELECT NAME="Usage">
<OPTION SELECTED>-- Please select an answer --
<OPTION>Looking at it for the first time today
<OPTION>Once or twice a month
<OPTION>Once or twice a week
<OPTION>Most days
<OPTION>Every day
<OPTION>Couldn't work without it
</SELECT>
<BR>
</P>
</BLOCKQUOTE>
<INPUT TYPE=SUBMIT VALUE="Submit Form">
<INPUT TYPE=RESET VALUE="Reset Form">
</FORM>