473,382 Members | 1,611 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,382 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 3684
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.