inserting variables into cookies

N

Navillus

Hi all,
I have a cookie setup to store usernames and passwords for my site.
Additionally, I'd like to store some variables in the cookie, and be
able to extract them back out. I'm having trouble doing this. Here's my
code thus far:

<head>
<!-- Javascript functions
***************************************************************** -->
<script>
function StartURL()
{
var service_sel = document.premise_selection.service_sel.value;
var premise = document.premise_selection.Premise_sel.value;

<!--- start of insert
-->
<!--- save the selected premise to ac cookie
-->
var nextyear = new Date();

nextyear.setFullYear(nextyear.getFullYear() + 1);

document.cookie = 'premise= '+ premise + '# expires='+
nextyear.toGMTString() +'; path= /';
<!--- end of insert
-->

var url = "http://`~http_host``~URLwgate`/" + service_sel + '!' +
'?EIAC-VSTELLE=' + premise + '&EIAC-OPBEL=' + " " + '&EIAC-WI_ID=' + "
" + '&~language=' + '`~language`';
parent.frames[2].location = url;
}

<!--- start of insert
-->
<!--- extract and use the value of the cookie named "premise"
-->
function GetPrem(prem)
{
var allcookies = document.cookie;
var position = allcookies.indexOf("premise=");
if (position != -1)
{
var start = position + 9;
var end = allcookies.indexOf(";", start); /* start of
cookie value */
if (end == -1) end = allcookies.length; /* end of value
*/
prem = allcookies.substring(start, end); /* extract value
*/
prem = unescape (prem); /* decode value
*/
}
}
<!--- end of insert
-->


</script>
</head>
<body `SAP_TemplateBodyAttributes()`>

<form name="premise_selection" method="post" action="`wgateurl()`">
<p>

<!--- start of insert
-->
<!--- over here, I'm calling the function GetPrem to get the previously
selected premise -->
<script> javascript:GetPrem(valueofprem); </script>
`premidx = 1`
<!--- end of insert
-->

<!-- pulldown field: premise -->
`for (j = 1; j <= PREMISE.dim; j++);`
`PremiseKey[j] = key[j];`
`PremiseContent[j] = premise[j];`
<!--- start of insert
-->
<!--- over here, I'm attempting to default the selection index to the
last premise selected -->
`if (valueofprem == key[j])`
`premidx = j`
`end`
<!--- end of insert
-->
`end`
 
R

RobG

Navillus said on 06/04/2006 1:26 PM AEST:
Hi all,
I have a cookie setup to store usernames and passwords for my site.
Additionally, I'd like to store some variables in the cookie, and be
able to extract them back out. I'm having trouble doing this.

#1 - ensure your HTML is valid, at present it's junk.
#2 - remove all HTML style comments from your script, they will
cause problems.
#3 - write valid JavaScript, use quotes consistently and nest them
properly
#4 - remove all the unrelated junk.
#5 - explain what the problems are - you are expecting others to
design some test cases based on what they think your code is
trying to do, run the test, then report all fixes for whatever
failures they can find.

Don't be surprised if there are no takers.

[...]
 
N

Navillus

RobG said:
Navillus said on 06/04/2006 1:26 PM AEST:
Hi all,
I have a cookie setup to store usernames and passwords for my site.
Additionally, I'd like to store some variables in the cookie, and be
able to extract them back out. I'm having trouble doing this.

#1 - ensure your HTML is valid, at present it's junk.
#2 - remove all HTML style comments from your script, they will
cause problems.
#3 - write valid JavaScript, use quotes consistently and nest them
properly
#4 - remove all the unrelated junk.
#5 - explain what the problems are - you are expecting others to
design some test cases based on what they think your code is
trying to do, run the test, then report all fixes for whatever
failures they can find.

Don't be surprised if there are no takers.

[...]

Which parts are junk?
 
T

Thomas 'PointedEars' Lahn

Navillus said:
RobG said:
Navillus said on 06/04/2006 1:26 PM AEST:
I have a cookie setup to store usernames and passwords for my site.
Additionally, I'd like to store some variables in the cookie, and be
able to extract them back out. I'm having trouble doing this.

#1 - ensure your HTML is valid, at present it's junk.
[...]
#4 - remove all the unrelated junk.
[...]
Group FAQ: <URL:http://www.jibbering.com/FAQ>

Which parts are junk?

All of it.

<URL:http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you>

If you had read the newsgroup's FAQ (and FAQ Notes) as recommended to you
many times now, probably you would have refrained from /continuing/ to post
like a complete idiot.


Score adjusted

PointedEars
 
N

Navillus

Thomas said:
Navillus said:
RobG said:
Navillus said on 06/04/2006 1:26 PM AEST:
I have a cookie setup to store usernames and passwords for my site.
Additionally, I'd like to store some variables in the cookie, and be
able to extract them back out. I'm having trouble doing this.

#1 - ensure your HTML is valid, at present it's junk.
[...]
#4 - remove all the unrelated junk.
[...]
Group FAQ: <URL:http://www.jibbering.com/FAQ>

Which parts are junk?

All of it.

<URL:http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you>

If you had read the newsgroup's FAQ (and FAQ Notes) as recommended to you
many times now, probably you would have refrained from /continuing/ to post
like a complete idiot.


Score adjusted

PointedEars

Many times now? Are you joking? No one has pointed me at the FAQ
before. I've posted maybe a dozen times, gotten good suggestions from
users (including yourself) in about half of them, and jackass responses
the rest of the time. If you don't want to help, just don't reply, and
the thread will drop to the bottom. Or, you could link me to the faq
before calling me a complete idiot. I'm being harassed by a man who, in
pretty much any other setting on the planet, is a complete twat. That's
what you get for toying on the internet I suppose... lots of pornstars
and social rejects.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top