473,563 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cookie s("CartID") = "3"
Response.Cookie s("CartID").Exp ires = "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 1775
What do you mean they don't work? What does this do?

cookieValue = Request.Cookies ("CartID")

<%
Response.Write "cookieValu e = """": " & (cookieValue = "") & "<br>"
Response.Write "IsNull(cookieV alue): " & IsNull(cookieVa lue) & "<br>"
Response.Write "So, then, the value is " & cookieValue
%>

Ray at home
"Andrew Duffy" <an****@freshwe b.com.au> wrote in message
news:ef******** ******@TK2MSFTN GP09.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.Cookie s("CartID") = "3"
Response.Cookie s("CartID").Exp ires = "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******** *****@tk2msftng p13.phx.gbl...
What do you mean they don't work? What does this do?

cookieValue = Request.Cookies ("CartID")

<%
Response.Write "cookieValu e = """": " & (cookieValue = "") & "<br>"
Response.Write "IsNull(cookieV alue): " & IsNull(cookieVa lue) & "<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
2862
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: setcookie ("cookieUser", $user); then the browser is sent with header("Location: spelersPage.php"); to another page. I there try to read the...
0
333
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: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchaspnetcookies101.asp under section: 'Checking Whether a Browser Accepts Cookies' This code works great, when its...
7
7174
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 time reaches the set expire-time. But if it is an expire time set on my server in California, and the cookie is put on a computer that is running...
2
1433
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 navigation to include a blinking 'NEW!' when that page has been updated within the last three days. It works fine for the one page (if you're on the news...
9
4474
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 in a cookie and a small bullit shown in front of the hyperlink, so when I reload the page I can immediately see which hyperlinks I already visited...
2
4754
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 = new HttpCookie(FormsAuthentication.FormsCookieName, sTicket); where sTicket is an encrypted FormsAuthenticationTicket. When I create the...
2
4804
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 exhausted all my other options, so I have to get this scenario working). Basically, if I POST the data normally, it works fine, except the target...
2
3724
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 a DLL, which is why I use HttpContext)... HttpCookie cookie = new HttpCookie("fred", "ferret");
1
8904
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 "Cookie: key=value\n\r" But, the control seems to ignore this header ( it's not seen on the
0
7659
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...
0
7580
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8103
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...
1
7634
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5481
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...
0
5208
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...
0
3634
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2079
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
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.