473,406 Members | 2,707 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,406 software developers and data experts.

Way to check for cookies

Is there a way to check to see if the browser accepts cookies? I have the
following line of code that is giving an error "Object reference not set to
an instance of an object."
with the following line:

If Server.HtmlEncode(Request.Cookies("level").Value) = "admin" Then

Thanks.
David
Nov 14 '08 #1
4 2258
not sure about the VB syntax , in c# it would be something like :

if ( Request.Cookies["level"]!=null &&
Server.HtmlEncode(Request.Cookies["level"].Value) == "admin" )
{
}

"David C" <dl*****@lifetimeinc.comwrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
Is there a way to check to see if the browser accepts cookies? I have the
following line of code that is giving an error "Object reference not set
to an instance of an object."
with the following line:

If Server.HtmlEncode(Request.Cookies("level").Value) = "admin" Then

Thanks.
David


Nov 14 '08 #2
Just curious. Why do you use Request.Cookies in one stmt and
Server.HtmlEncode(Request.Cookies... in another? Are they equivalent?

David
"gerry" <ge***@newsgroup.nospamwrote in message
news:O9*************@TK2MSFTNGP06.phx.gbl...
not sure about the VB syntax , in c# it would be something like :

if ( Request.Cookies["level"]!=null &&
Server.HtmlEncode(Request.Cookies["level"].Value) == "admin" )
{
}

"David C" <dl*****@lifetimeinc.comwrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
>Is there a way to check to see if the browser accepts cookies? I have
the following line of code that is giving an error "Object reference not
set to an instance of an object."
with the following line:

If Server.HtmlEncode(Request.Cookies("level").Value) = "admin" Then

Thanks.
David



Nov 14 '08 #3
in c# if are short circuited

if (a && b)

if a is false, b will not be evaluated. this is not tue for vb, you will
need to do two if statements. assuming i can remember vb syntax at all:

If not Request.Cookies("level") is nothing then
if Server.HtmlEncode(Request.Cookies("level").Value) = "admin" Then

end if
end if

also have no idea why you call Server.HtmlEncode().

-- bruce (sqlwork.com)
"David C" wrote:
Just curious. Why do you use Request.Cookies in one stmt and
Server.HtmlEncode(Request.Cookies... in another? Are they equivalent?

David
"gerry" <ge***@newsgroup.nospamwrote in message
news:O9*************@TK2MSFTNGP06.phx.gbl...
not sure about the VB syntax , in c# it would be something like :

if ( Request.Cookies["level"]!=null &&
Server.HtmlEncode(Request.Cookies["level"].Value) == "admin" )
{
}

"David C" <dl*****@lifetimeinc.comwrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
Is there a way to check to see if the browser accepts cookies? I have
the following line of code that is giving an error "Object reference not
set to an instance of an object."
with the following line:

If Server.HtmlEncode(Request.Cookies("level").Value) = "admin" Then

Thanks.
David



Nov 14 '08 #4
I was probably brain dead when I coded this page. Normally I just use
If Not Request.Cookies("level") Is Nothing Then
....

David
"bruce barker" <br*********@discussions.microsoft.comwrote in message
news:1B**********************************@microsof t.com...
in c# if are short circuited

if (a && b)

if a is false, b will not be evaluated. this is not tue for vb, you will
need to do two if statements. assuming i can remember vb syntax at all:

If not Request.Cookies("level") is nothing then
if Server.HtmlEncode(Request.Cookies("level").Value) = "admin" Then

end if
end if

also have no idea why you call Server.HtmlEncode().

-- bruce (sqlwork.com)
"David C" wrote:
>Just curious. Why do you use Request.Cookies in one stmt and
Server.HtmlEncode(Request.Cookies... in another? Are they equivalent?

David
"gerry" <ge***@newsgroup.nospamwrote in message
news:O9*************@TK2MSFTNGP06.phx.gbl...
not sure about the VB syntax , in c# it would be something like :

if ( Request.Cookies["level"]!=null &&
Server.HtmlEncode(Request.Cookies["level"].Value) == "admin" )
{
}

"David C" <dl*****@lifetimeinc.comwrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
Is there a way to check to see if the browser accepts cookies? I have
the following line of code that is giving an error "Object reference
not
set to an instance of an object."
with the following line:

If Server.HtmlEncode(Request.Cookies("level").Value) = "admin" Then

Thanks.
David




Nov 14 '08 #5

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

Similar topics

5
by: TG | last post by:
This is more of a pain than I thought it would be. I need a simple code segment to determine whether a browser accepts cookies or not. When I pass variables between pages when cookies are turned...
27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
7
by: | last post by:
It is possible to check via ASP whether cookies are enabled for a person's web browser and based on this check send him to another page which does not support cookies (ie login?)? Thanks Jason
11
by: Jennifer | last post by:
Is there a way to check for to see if the user has session cookies enabled? I know how to check to see if they have cookies in general enabled, but how do you test for just session cookies? ...
0
by: Steve Johnson | last post by:
I've set IE 6.0 (in Windows XP) to block all cookies, yet Response.Browser.Cookies. still returns True. Additionally, attempts to write cookies are successful. Here's a code snippet. Does...
4
by: mike parr | last post by:
I'm trying to do a check to see if the client browser has cookies enabled. But my code below always gives me the value for acceptsCookies = true, whether the machine has cookies enabled or not. ...
1
by: wrytat | last post by:
How do you check in the vb codes whether the user has enabled the option to accept cookies in his web browser? Thank you in advance.
1
by: Bobby Edward | last post by:
How do I check to see if a cookie exists or not? I tried these 3 but they don't work... If Not Request.Cookies("UserSettings")("IsAdmin") Is Nothing Then... If...
3
by: =?Utf-8?B?Qkw=?= | last post by:
if (Request.Browser.Cookies) { // Cookies supported } else { // Web browser not supports cookies }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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,...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
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...

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.