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

  • Thread starter Thread starter user
  • Start date Start date
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
 
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
 
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
 
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
}
 
Back
Top