473,626 Members | 3,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.d ocument.all.Doo rs.value=form1. Doors.value;

i have only ever used the following to set cookies in vbscript
<input type="hidden" value="<%=Reque st.Cookies("Doo rs")%>"
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 3706
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="<%=Reque st.Cookies("Doo rs")%>"
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.javas cript:
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.10 9.133.29>,
ex************* *@interxnl.net enlightened us with...
kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
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.javas cript:
In article <Xn************ ********@194.10 9.133.29>,
ex************* *@interxnl.net enlightened us with...
kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
> 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.javas cript:
In article <Xn************ ********@194.10 9.133.29>,
ex************* *@interxnl.net enlightened us with...
kaeli wrote on 25 apr 2005 in comp.lang.javas cript:

> 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.get UserName() %></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.javas cript:
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.get UserName() %></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.10 9.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.javas cript:
In article <Xn************ ********@194.10 9.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.10 9.133.29>,
ex************* *@interxnl.net enlightened us with...
kaeli wrote on 25 apr 2005 in comp.lang.javas cript:
In article <Xn************ ********@194.10 9.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
2577
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 value for a URLConnection object in a Java class to obtain the results of this page to get, of all things, a cookie value. Simply put: it's the ONLY way I know of where I can use Java to ultimately obtain a cookie since this is an application...
2
5563
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 want to override the last value set in the onunload event, it has no effect. The next onload still has the old value. Any ideas? The following code simulates the problem I experience. --------------------------------------------------
5
2084
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" ' also tried with document.cookie="name=mycookie"
17
1834
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
5961
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 the value of that session cookie in response to a button click in a form, without resubmitting the page. For some reason, the following doesn't seem to work:
9
5505
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 http://www.developersdex.com ***
1
1958
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 french or english. I want to set a cookie to persist that choice each time the user comes back on the intranet. This feature must be available everywhere on the intranet and the link is placed in an inner asp script called Menu.asp which is...
2
5319
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 cookieValue; expireDate.setMinutes(expireDate.getMinutes() + minutesToExpire);
1
5775
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 stored in my computer i dont this cookie
0
8262
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6122
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5571
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2623
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 we have to send another system
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1507
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.