codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  How to check whether the cookie is there or not ??  Ragnarok at 04:17 on Saturday, March 27, 2004
 

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 ^^

  Re: How to check whether the cookie is there or not ??  Troy Wolf at 14:16 on Monday, March 29, 2004
 

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.
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: How to check whether the cookie is there or not ??  Ragnarok at 01:42 on Thursday, April 01, 2004
 

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...

  Re: How to check whether the cookie is there or not ??  Troy Wolf at 02:31 on Thursday, April 01, 2004
 

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
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: How to check whether the cookie is there or not ??  Ragnarok at 06:56 on Thursday, April 01, 2004
 

Wah wah...thank u so much..i managed to solve the problem ^_^...
Thanks yah =)








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  popup image loading problem
•  C++
•  Re: refresh parent after closing pop up window
•  Dynamic Insertion
•  Date and Time function around the world???
•  Significant Factors
•  Perl array access
•  Re: huffman encoding and decoding in C++...
•  Perl One Liner: Replace {(


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009