473,243 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,243 software developers and data experts.

Set cookie in javascript and retrieve it in vbscript ??

hi folks,

just wonder if this is possible or is there a better way of doing
this. i need to store values in cookies between two forms. the details
are added in a popup when this is closed the main form stores these
values in hidden fields. at this point xml is built up and submitted
to a biztalk server. if there is an error the page is refreshed and
the initial values i added via the popup are lost.

my idea was to store these as cookies and populate the main form that
way if there is an error. My popup uses the following to send details
back to main form. e.g.,
window.opener.document.all.Doors.value=form1.Doors .value;

i have only ever used the following to set cookies in vbscript
<input type="hidden" value="<%=Request.Cookies("Doors")%>"
name="Doors" >

how can i set and get cookies using purely javascript ??? any examples
greatly appreciated.

Thanks in advance.

CG
Jul 23 '05 #1
9 3669
In article <ee**************************@posting.google.com >, csgraham74
@hotmail.com enlightened us with...
hi folks,

just wonder if this is possible or is there a better way of doing
this.
Best way (IMO) is with session variables, that way if someone has cookies
turned off or JS turned off, it still works.

i have only ever used the following to set cookies in vbscript
<input type="hidden" value="<%=Request.Cookies("Doors")%>"
name="Doors" >

how can i set and get cookies using purely javascript ??? any examples
greatly appreciated.


Not like this. ;)
You'd have to set the cookie by calling a function somewhere, probably form
onsubmit. And you can't call javascript code in a value like you do here with
ASP.
There are cookie functions posted here all the time, so a quick Google of the
group should bring some up. If you can't find any, I have a very simplistic
cookie function set (check, set, and get, simple values, no domains) in my
useful section in Kaeli's Space (see my sig).

--
--
~kaeli~
The Bermuda Triangle got tired of warm weather. It moved to
Finland. Now Santa Claus is missing.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
kaeli wrote on 25 apr 2005 in comp.lang.javascript:
Best way (IMO) is with session variables, that way if someone has
cookies turned off or JS turned off, it still works.


Not exactly.
If session cookies are also turned off,
every page is a new session,
without any session variables to start with.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #3
In article <Xn********************@194.109.133.29>,
ex**************@interxnl.net enlightened us with...
kaeli wrote on 25 apr 2005 in comp.lang.javascript:
Best way (IMO) is with session variables, that way if someone has
cookies turned off or JS turned off, it still works.


Not exactly.
If session cookies are also turned off,
every page is a new session,
without any session variables to start with.


Most servers I have worked with fall back to URL re-writing if session
cookies are disabled.
If yours does not, then you should have all sessions use URL re-writing for
precisely this reason.

i.e. from the weblogic docs:
Using URL Rewriting Instead of Cookies
In some situations, a browser or wireless device may not accept cookies,
which makes session tracking with cookies impossible. URL rewriting is a
solution to this situation that can be substituted automatically when
WebLogic Server detects that the browser does not accept cookies.

--
--
~kaeli~
The secret of the universe is @*&^^^ NO CARRIER
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4
kaeli wrote on 25 apr 2005 in comp.lang.javascript:
In article <Xn********************@194.109.133.29>,
ex**************@interxnl.net enlightened us with...
kaeli wrote on 25 apr 2005 in comp.lang.javascript:
> Best way (IMO) is with session variables, that way if someone has
> cookies turned off or JS turned off, it still works.
>
Not exactly.
If session cookies are also turned off,
every page is a new session,
without any session variables to start with.


Most servers I have worked with fall back to URL re-writing if session
cookies are disabled.


I have no idea what you are talking about.

Are you talking ASP, Kaeli?
If yours does not, then you should have all sessions use URL
re-writing for precisely this reason.

i.e. from the weblogic docs:
Using URL Rewriting Instead of Cookies
In some situations, a browser or wireless device may not accept
cookies, which makes session tracking with cookies impossible. URL
rewriting is a solution to this situation that can be substituted
automatically when WebLogic Server detects that the browser does not
accept cookies.


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #5
In article <Xn*******************@194.109.133.29>,
ex**************@interxnl.net enlightened us with...
kaeli wrote on 25 apr 2005 in comp.lang.javascript:
In article <Xn********************@194.109.133.29>,
ex**************@interxnl.net enlightened us with...
kaeli wrote on 25 apr 2005 in comp.lang.javascript:

> Best way (IMO) is with session variables, that way if someone has
> cookies turned off or JS turned off, it still works.
>

Not exactly.
If session cookies are also turned off,
every page is a new session,
without any session variables to start with.

Most servers I have worked with fall back to URL re-writing if session
cookies are disabled.


I have no idea what you are talking about.


Then why did you argue? ;)

Are you talking ASP, Kaeli?


No, actually Weblogic (WSAD) is JSP.
But ASP (IIS) can do it too. As can Cold Fusion. I don't think Apache /
Tomcat can auto-detect, but I dunno for sure. I don't think NES (Iplanet)
can, either, but 6.0 had some nice changes, so maybe it can now.

Session variables != session cookie.

Session variables are used (implemented) by a web server, but generally
implemented by whatever server-side scripting language you're using.
This has nothing at all to do with javascript unless we're talking JScript
with .net or some such. The OP said he was open to other ideas, so I gave him
one.
For example, in my web app, I store the user's name in a session variable,
along with several user preferences. These are loaded from the DB when the
user logs in. They are not stored on the client. The client gets only a
session ID, which points to that data on the server so I don't have to query
the DB over and over. Then, I can do something like
<p>Welcome <%= sessionBean.getUserName() %></p>

HTH

--
--
~kaeli~
I do whatever my Rice Krispies tell me to.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #6
kaeli wrote on 25 apr 2005 in comp.lang.javascript:
Are you talking ASP, Kaeli?


No, actually Weblogic (WSAD) is JSP.
But ASP (IIS) can do it too. As can Cold Fusion. I don't think Apache
/ Tomcat can auto-detect, but I dunno for sure. I don't think NES
(Iplanet) can, either, but 6.0 had some nice changes, so maybe it can
now.

Session variables != session cookie.

Session variables are used (implemented) by a web server, but
generally implemented by whatever server-side scripting language
you're using. This has nothing at all to do with javascript unless
we're talking JScript with .net or some such. The OP said he was open
to other ideas, so I gave him one.
For example, in my web app, I store the user's name in a session
variable, along with several user preferences. These are loaded from
the DB when the user logs in. They are not stored on the client. The
client gets only a session ID, which points to that data on the server
so I don't have to query the DB over and over. Then, I can do
something like <p>Welcome <%= sessionBean.getUserName() %></p>


This is neither here nor there, Kaeli.

If the server does not recognize the client session, the server can store
al it likes, but does not know which client connection and session the
stored data belong to.

So the server either needs a session cookie [a cookie that expires at the
closing of the browser, also named ram-cookie] or a session code has to be
sent as a form or query value with all pages.

Is it the latter you mean.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #7
In article <Xn********************@194.109.133.29>,
ex**************@interxnl.net enlightened us with...

If the server does not recognize the client session, the server can store
al it likes, but does not know which client connection and session the
stored data belong to.


Yes, it does.
It uses the URL if it can't use cookies. As I said.

--
--
~kaeli~
A chicken crossing the road is poultry in motion.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #8
kaeli wrote on 25 apr 2005 in comp.lang.javascript:
In article <Xn********************@194.109.133.29>,
ex**************@interxnl.net enlightened us with...

If the server does not recognize the client session, the server can
store al it likes, but does not know which client connection and
session the stored data belong to.


Yes, it does.
It uses the URL if it can't use cookies. As I said.


A strange way of describing URL.
I would call it the querystring.

Anyway, since my users want something from me,
I am not going to accomodate them.

If they switch off ram-cookies, they loose functionality.

If they buy a car,
they should know it does not run without petrol,
and I am not going to push it.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #9
In article <Xn********************@194.109.133.29>,
ex**************@interxnl.net enlightened us with...
kaeli wrote on 25 apr 2005 in comp.lang.javascript:
In article <Xn********************@194.109.133.29>,
ex**************@interxnl.net enlightened us with...

If the server does not recognize the client session, the server can
store al it likes, but does not know which client connection and
session the stored data belong to.


Yes, it does.
It uses the URL if it can't use cookies. As I said.


A strange way of describing URL.
I would call it the querystring.

Anyway, since my users want something from me,
I am not going to accomodate them.


You don't work on e-commerce and B2B applications, do you?

--
--
~kaeli~
If a chicken and a half can lay an egg and a half in a day
and a half, how long would it take for a monkey with a
wooden leg to kick the dill seeds out of a pickle?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #10

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

Similar topics

0
by: Phil Powell | last post by:
URL: http://valsignalandet.com/cookiegrab.php?name=valIdentifier This page produces a cookie value and sends it back as HTML using PHP and Javascript to obtain it. This URL will be used as the...
2
by: Michael | last post by:
I am reading and setting a cookie using JavaScript in the BODY onload and onunload events respectively. This works fine. However when I use ASP to set the cookie under some condition where I...
5
by: Carl | last post by:
Hi, I want to pass the value of the cookie created in VB to ASP. This doesn't work. Any idea? Thanks Carl .... <script language=vbscript> document.cookie="mycookie" '...
17
by: neerolyte | last post by:
how would i go about setting a cookie in javascript that can be read in javascript on the next page load, but will NOT be passed to the server?
3
by: M Wells | last post by:
Hi All, Just wondering how you go about changing the value of a session cookie via javascript? I have a PHP page that sets a session cookie when it first loads. I'd like to be able to change...
9
by: Mike Reed | last post by:
I must be having a "senile" day! I cannot recall, nor get to work, code to read a cookie's expiration date/time in an ASP page/VBScript. What am I missing? *** Sent via Developersdex...
1
by: Stef | last post by:
Hi people, I have a problem with cookies set via javascript. What I try to achieve is, when a user comes on the intranet, he can click on a link ( a simple href) that will set the content to...
2
by: Josh T | last post by:
As of now I am setting a cookie on my aspx page via javascript, function SetCookie(cookieName, value, minutesToExpire) { ClearCookie(cookieName); var expireDate = new Date(); var...
1
oranoos3000
by: oranoos3000 | last post by:
hi i want to set cookie with javascript i use this code <script language="javascript"> document.cookie="username='ali'"; </script> with using this code when i look at previous cookie that...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.