I'm new to ASPX. In my .aspx page I set multiple cookies from the session
variables to the "visitor" container:
dim cookie as HttpCookie
cookie=new HttpCookie("vis itor")
cookie.Values.A dd("cid", Session("sid"))
cookie.Values.A dd("ckeywords", Session("skeywo rds"))
cookie.Values.A dd("ccampaignno ",Session("scam paignno"))
cookie.Values.A dd("cadgroup",S ession("sadgrou p"))
cookie.Expires = Now.AddDays(365 )
response.append cookie(cookie)
But I need to set those cookies only if they do not exist on the computer.
If I surround the code with if-then statement that looks like this:
If Request.Cookies ("visitor") is Nothing Then
dim cookie ....
...
...
response.append ...
end if
the browser gives me an error.
My question is how do I check if the container "visitor" exists in cookies?
Thank you for your time. 2 1186
Sorry -
Forgot to include the error:
If the cookies "visitor" do not exist the error is:
Exception Details: System.NullRefe renceException: Object reference not set
to an instance of an object.
"William" <da@northernit. net> wrote in message
news:Cc******** ********@twiste r.nyroc.rr.com. .. I'm new to ASPX. In my .aspx page I set multiple cookies from the session variables to the "visitor" container:
dim cookie as HttpCookie cookie=new HttpCookie("vis itor") cookie.Values.A dd("cid", Session("sid")) cookie.Values.A dd("ckeywords", Session("skeywo rds")) cookie.Values.A dd("ccampaignno ",Session("scam paignno")) cookie.Values.A dd("cadgroup",S ession("sadgrou p")) cookie.Expires = Now.AddDays(365 ) response.append cookie(cookie)
But I need to set those cookies only if they do not exist on the computer. If I surround the code with if-then statement that looks like this:
If Request.Cookies ("visitor") is Nothing Then
dim cookie .... ... ... response.append ...
end if
the browser gives me an error.
My question is how do I check if the container "visitor" exists in
cookies? Thank you for your time.
William wrote: I'm new to ASPX. In my .aspx page I set multiple cookies from the session variables to the "visitor" container:
dim cookie as HttpCookie cookie=new HttpCookie("vis itor") cookie.Values.A dd("cid", Session("sid")) cookie.Values.A dd("ckeywords", Session("skeywo rds")) cookie.Values.A dd("ccampaignno ",Session("scam paignno")) cookie.Values.A dd("cadgroup",S ession("sadgrou p")) cookie.Expires = Now.AddDays(365 ) response.append cookie(cookie)
But I need to set those cookies only if they do not exist on the computer. If I surround the code with if-then statement that looks like this:
If Request.Cookies ("visitor") is Nothing Then
dim cookie .... ... ... response.append ...
end if
the browser gives me an error.
My question is how do I check if the container "visitor" exists in cookies?
That code is fine -- the error must be at a different line in your
code.
Note that is not a "browser error", but a simple coding error in your
code behind class, which you can easily debug...
Cheers,
-- http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
Is it possible for a user to enable permanent cookies but disable session
cookies.....this seems like a contradition yet this is what I appear to be
reading in online articles?
|
by: Mark |
last post by:
Hi...
I've come across some weird bug with Response.Cookies. Or maybe it will be
called "by design" but for the life of me I can't figure out what purpose it
would serve. If you're setting a cookie (say Response.Cookies ("TEST")) and
you have a query string variable &test=x or &Test=x and you get
Request.QueryString to parse the query string, the cookie that gets dropped
matches the case of the query string, not what your code says. ...
|
by: CDARS |
last post by:
Hi all,
I have a confusing question on ASP.NET cookies usage:
1> Response.Cookies("test").value = Now
2> Response.Write(Request.Cookies("test").value)
3>
4> Response.write("<hr>")
5>
6> Response.Cookies("test").value = Now.AddDays(10)
|
by: Alex Nitulescu |
last post by:
Sorry, I'm really confused - I'm only at the middle of my book and already I
can count 4 methods to store values.
Yes, I know that cookies can not store much, but what is the difference
between storing data in the cache object, in a viewstate and in a Session.
I can say
Cache("MyData")=objDataSet
as well as
|
by: Cheung, Jeffrey Jing-Yen |
last post by:
I have a windows form application that generates a request, downloads an image, and waits the user
to enter in login info. Unfortunately, this image is dynamic and based on session data. I have
read documents on the CookieCollection property of HttpWebRequest. Currently, I have the
functionality in my code to be able to accept cookies, and return them upon a new HttpWebRequest;
however, upon further inspection of the returning...
| |
by: Phillip N Rounds |
last post by:
I'm having trouble with using cookies to monitor the stages of login.
I have a two stage Registration page ( register.aspx ) and my target page
( MyPage.aspx )
I'm using a cookie named LoginStatus to tract the stage of the login
process.
LoginStatus = "1" denotes that the first part of the login process has been
performed.
LoginStatus = "2" denotes that the login process has been completed.
|
by: John A. Bailo |
last post by:
This is a general web development question about persistant cookies.
I thought I would use persistant cookies to indentify unique visitors to
my site.
When testing my cookie setting code, I found that the cookies are
persistant in IE6, but in Firefox 1.5 they ended up being session
cookies. Then I see that there is a drop down to set all cookies to
being session cookies (cookies disappear "when I close Firefox").
|
by: yawnmoth |
last post by:
If running off of the local filesystem, in Firefox, or if the security
settings are set appropriately, in Internet Exporer, XmlHttpRequests
can be sent to any domain of your chosing. But what about cookies?
Can cookies be accessed for any domain of your chosing?
For example, although www.domaina.tld can't access cookies for
www.domainb.tld, can c:\ access cookies for www.domainb.tld?
The way cookies are accessed in javascript...
|
by: Kevin Blount |
last post by:
I've setup a method (C#) that I can call, passing it a cookie name,
then a name-value pair. The idea is that as I can't append to a cookie,
I read the cookie value, append by name=pair to the end and write it
back... which works fine for adding a single name-value pair on a page.
The problem is, I want/need to add multiple name-values pairs, the
number of which changing between pages (some might have 3, another 8).
In my test scripts...
|
by: André |
last post by:
Hi,
I need several cookies depending of an variable (x), so i defined a
HttpCookie() as an array.
My problems:
1)I get the error: Object reference not set to an instance of an object.
2)My second question is: how to request those cookies, because there is no
name?
Thanks
|
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...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |