473,473 Members | 4,208 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

inserting variables into cookies

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`

Apr 6 '06 #1
4 1623
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.

[...]
--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Apr 6 '06 #2
RobG wrote:
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.

[...]
--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>


Which parts are junk?

Apr 6 '06 #3
Navillus wrote:
RobG wrote:
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
Apr 6 '06 #4
Thomas 'PointedEars' Lahn wrote:
Navillus wrote:
RobG wrote:
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.

Apr 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brad | last post by:
Hi everyone, I've been using ASP on a few different projects over the past year, either using Javascript or VBScript. During that time, I've made use of session variables, but even then, I've...
14
by: qaz | last post by:
I've always used session cookies in my web sites. However, since more and more people (including me) are starting to disable cookies, I'm beginning to think that I should change my ways and design...
0
by: Pat Allan | last post by:
I've spent half a day on this with no success, so I'm hoping someone can point out what I'm doing wrong. I have an ASP.NET Server-side component that I've created, and as part of its Render...
1
by: Steve Remer | last post by:
My application (relevant code snippets below) originally used Session variables in order to maintain state from page to page. After being unable to solve the mystery of why those variables were...
5
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global...
4
by: leena13 | last post by:
Hi, I am facing a problem of loss of session variables once the ASP.Net 2.0 application is deployed. Let me add that this is actually a 1.1 to 2.0 migration. I found that the first time the...
22
by: K. A. | last post by:
I have two servers at work, 'A' for testing and development, and server 'B' for production. On server A, I wrote a PHP test code to login users then direct them to a personalized page. This is...
3
by: damezumari | last post by:
To find out were session variables are stored I included this instruction in my program: echo ini_get("session.save_path"); The reply was /home/7604/data/tmp which is a folder on my server. I...
103
by: chochote | last post by:
Hi, I have a PHP script that does some processing, and stores an error message as a variable. The script then redirects to another script with the error string in the URL, with the second script...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.