What's the proper way of reading cookies? Request.Cookies("mycook") doesnt work

U

user

Hi everyone,

May I know the standard way of reading in cookies in ASP.net using
VB.net?

In classic asp, i can do this:

If request.cookies("user") = "abc" then

blah blah

end if

But if i were to do the same in asp.net,

I would hit an ugly error.

What is the proper way of detecting cookies?

Thanks
 
M

Masudur

Hi everyone,

May I know the standard way of reading in cookies in ASP.net using
VB.net?

In classic asp, i can do this:

If request.cookies("user") = "abc" then

blah blah

end if

But if i were to do the same in asp.net,

I would hit an ugly error.

What is the proper way of detecting cookies?

Thanks

Hi........

Here is a quick link.... from asp.net quick start...
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/applications/state.aspx#cookies

Thanks...
Masudur
http://www.kaz.com.bd
http://munnacs.blogspot.com
 
M

Mark Rae

In classic asp, i can do this:

If request.cookies("user") = "abc" then

blah blah

end if

But if i were to do the same in asp.net,

I would hit an ugly error.

Would you...? What ugly error would you hit...?
What is the proper way of detecting cookies?

If Request.Cookies("user") = "abc" Then
' blah blah
End If
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

user said:
Hi everyone,

May I know the standard way of reading in cookies in ASP.net using
VB.net?

In classic asp, i can do this:

If request.cookies("user") = "abc" then

blah blah

end if

But if i were to do the same in asp.net,

I would hit an ugly error.

What is the proper way of detecting cookies?

Thanks

The difference in .NET is that what you get from the Request.Cookies
collection is an HttpCookie object instead of a string. If the cookie
doesn't exist, you get a null reference instead of an empty string.

HttpCookie user = Request.Cookies("user");
if (user != null && user.Value == "abc") {
//blah blah
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top