473,395 Members | 1,694 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,395 software developers and data experts.

Checking if a cookie has already been set


Hi,

I just want to check that i'm not going crazy.. I want to check
whether or not a cookie has already been set and so I am using the
following code.

cookieValue = Request.Cookies("CartID")
'if cookie hasn't already been set, then set it!
If cookieValue = "" Then

Response.Cookies("CartID") = "3"
Response.Cookies("CartID").Expires = "Jan 1, 2005"

End if

I have also used IsNull yet both just don't seem to work.... am I
missing something here?

Thanks heaps
Andrew Duffy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #1
2 1770
What do you mean they don't work? What does this do?

cookieValue = Request.Cookies("CartID")

<%
Response.Write "cookieValue = """": " & (cookieValue = "") & "<br>"
Response.Write "IsNull(cookieValue): " & IsNull(cookieValue) & "<br>"
Response.Write "So, then, the value is " & cookieValue
%>

Ray at home
"Andrew Duffy" <an****@freshweb.com.au> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...

Hi,

I just want to check that i'm not going crazy.. I want to check
whether or not a cookie has already been set and so I am using the
following code.

cookieValue = Request.Cookies("CartID")
'if cookie hasn't already been set, then set it!
If cookieValue = "" Then

Response.Cookies("CartID") = "3"
Response.Cookies("CartID").Expires = "Jan 1, 2005"

End if

I have also used IsNull yet both just don't seem to work.... am I
missing something here?

Jul 19 '05 #2
Yeah, perhaps I should have put the first line in the script block too...
Oops.

Ray at home

"Ray at <%=sLocation%>" <myfirstname at lane 34 . komm> wrote in message
news:ek*************@tk2msftngp13.phx.gbl...
What do you mean they don't work? What does this do?

cookieValue = Request.Cookies("CartID")

<%
Response.Write "cookieValue = """": " & (cookieValue = "") & "<br>"
Response.Write "IsNull(cookieValue): " & IsNull(cookieValue) & "<br>"
Response.Write "So, then, the value is " & cookieValue
%>

Jul 19 '05 #3

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

Similar topics

3
by: Stijn Goris | last post by:
hi all, Trying to get those cookies to work but they wont... Doing this. Have a page login.php wich tests the user and pass. If they are correct a cookie is set with one variable like this:...
0
by: Lucifer | last post by:
Hi I have some code for checking for cookies, that sets a cookie on page1 and checks for it on page2. and its based on the code by MS: ...
7
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local...
2
by: Christopher | last post by:
Hi all, Sorry if this is a silly question but I've been having a heck of a hard time with it and hope somebody here can lend me a hand. I have a site with a news pages and I'd like the...
9
by: Marco Krechting | last post by:
Hi All, I have a page with a list of hyperlinks. I want to save information in a cookie about the fact that I entered an hyperlink or not. When I click one of the hyperlinks I want this stored...
2
by: George Durzi | last post by:
When you call FormsAuthentication.SignOut(), is the FormsAuthentication cookie supposed to be destroyed automatically? I'm creating my FormsAuthentication cookie by doing: HttpCookie oCookie =...
2
by: Keith Patrick | last post by:
I'm trying to programmatically post data to another page within my ASP.Net app. Not POSTing is not an option (I can't store this data in my session, context, hidden fields, or anything else...I've...
2
by: Alan Silver | last post by:
Hello, I have discovered that if I try and add a cookie when one by that already exists, nothing happens. No error, but the cookie is not set to the new value. For example (this is running in...
1
by: claes R | last post by:
Hi ! I am trying to add a cookie to a webbrowser component hosted inside a windows forms window and perform a call. ala, browser.Navigate( xxx,yyy, zzz, strHeader) where strHeader contains...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.