|
I have a page in which users log into my website. If the login is successful, then a cookie named "Username" is sent to them. I need all the other pages on the website to check for this cookie's existence before allowing users access to any pages.. Is there a way of just checking to see if the cookie exists? Can someone please help?
Btw, i am using C#.net to code the website.. Any help is appreciated
Thanks ^^
|
|
|
Test the value of the cookie. If the value is null or "", then consider the cookie does not exist. I assume that in your case, that if the cookie really does not exist or is blank, it's really the same thing to you.
|
|
|
|
|
Yeah...but can u help me one more things? what the syntax to check whether the cookies is null or not? i find it difficult to find the syntax...
thanks...
|
|
|
I'm not an ASP.net developer, so I'm not really qualified to give you an answer, but right here on good ole' codetoad is an article regarding ASP.net Cookies. How did I know this? I went to Google and searched for "ASP.net Cookies", and codetoad.com was the first hit. Anyway.....that article is here: http://www.codetoad.com/asp.net/cookies.asp
I pretty sure this is all you have to do:
myBackgroundColor = Response.Cookies["BackgroundColor"].Value
if myBackgroundColor <> "" then
'coookie has a value
else
'cookie does not have a value
end if
|
|
|
|
|
|
|
Wah wah...thank u so much..i managed to solve the problem ^_^...
Thanks yah =)
|
|
|