How do I get and/or set cookies using client-side VB script?
Printable View
How do I get and/or set cookies using client-side VB script?
dont try this, cookies are good for server side only.
Cookies are set through the Response object which is server side only.
thanks for the response, but that's not what i expected i'm affraid.
what i want to achieve is that to not bother to go to the server if the cookie is not there anyway....
client-side cookie handling is possible using javascript, so i presume that vbscript should be able to do the same...
anyone?
VBScript generally uses the same Object Model as Javascript/JScript, just the syntax is different.
From MSDN:
Code:<SCRIPT LANGUAGE="VBSCRIPT">
Sub SetCookie
document.cookie = "MyVar='101'; path='page1-2.htm'"
End Sub
</SCRIPT>
Okay, if u need the cookie stuff done on the client side, then what is wrong with using Javascript?
Its as simple as document.cookie
all u do is make it equal to a string with the variable u need in the cooke and the date...to know when the cookie expires.
I can put all the code here if u want. Just don't remember it off hand.
But lemme know why u want to use VBscript for something that as far as I know Javascript is more than adeopt at handling?
:confused:
Well, i need to use vbscript because i'm writing an intranet application for users using IE5 up, and it need to do some stuff on the client machine. Since it's intranet, the security is set to allow this. Javascript does not have the possibility to do stuff on the client machine. That's why.
By the way, thanx JoshT for the setcookie code, is there one also for [b]get[b]cookie?
cheers
You're welcome. Not off hand, but if you have an example using client side javascript, all you'd have to do is modify the syntax for vbscript.