Click here to Skip to main content
15,907,396 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi to all,

I am a beginner and working on building websites on asp.net platform in visual studio 2008. I have created a basic login system. Now I used cookie to store username in it so that I can use it to access the respective database.

For example. a person with username abc logins. It is redirected to profile page. Now here I want to show his profile details in a list view but could not do. So I thought to use username stored in the cookie to fill the SQL WHERE condition to search the table details of that person and fill it in the LIST VIEW.

So how can I get the cookie information. As I have tried but I access all the information of it at once like "9 may 2011 12:22:20 uid=abc"

If there is another way of showing the information of a particular registered user after he log in then please help me out.

Thanks to U.
Posted

This article too would help you out: Beginner's Guide To ASP.NET Cookies[^]
 
Share this answer
 
See MSDN Reading a Cookie[^] - it's pretty simple!
 
Share this answer
 
Comments
ani4hp 9-May-11 3:02am    
<pre><pre lang="xml">HttpCookie myCookie = new HttpCookie("MyTestCookie");
myCookie = Request.Cookies["MyTestCookie"];
// Read the cookie information and display it.
if (myCookie != null)
Response.Write("<p>"+ myCookie.Name + "<p>"+ myCookie.Value);
else
Response.Write("not found");</pre>
</pre>

This is the example I got but I want to use the value to display it in a label control. But I assign it I get error saying cannot convert void to string.
ani4hp 9-May-11 3:06am    
I am using cookie to get the username after authentication so that when the user goes to profile page he see his own details in list view.
OriginalGriff 9-May-11 3:17am    
Then check that you have written it into the right cookie!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900