Hello!

1) I have no idea how to use Session objects, especially when it has to remember the Session of the logged user. When the user clicks logout, his session should be removed until the next time he logs in.

2) Also, how to validate the user in such a way that the user shouldn't sign up or log in as Admin of the website. Only customers can login as customers and Admins can log in as Admins.

Thanks..

Recommended Answers

All 6 Replies

Hi,
This is a bit of theory that might give a bit of idea about sessions. Because every programmer working for Web/or such applications loves to deal with session,i would love to help you with this problem.


ASP.NET Session state provides a place to store values that will persist across page requests. Values stored in Session are stored on the server and will remain in memory until they are explicitly removed or until the Session expires.

Storing and retrieving a value in the Session is as simple as:

VB

Session("Name") = "John Doe"'orSession.Add("Name","John Doe")'retrieving

Dim Name As String = Session("Name")

C#

Session["Name"] = "John Doe";//orSession.Add("Name","John Doe");//retrievingstring

Name = (string)Session["Name"];

This is the link where you will get a code snippet and more detailing

SessionExample

Happy Coding :)

I always find Session difficult, anyway, thanks for the help. I'll read that blog. Do you happen to know the codes for implementing session of a user?

Yes i know how to check whether user is logged in or not through sessions.
Infact that example also contains all you want,but if you want it to be simple and more easy then write here,i will provide you with a sample example.

Yes. tell me the easier way

Wait till tomorrow,i will write here a complete code with database and login page,that how session works.

Till that time,Happy codding :)

wow!! Thank you so much :D I really needed those codes. I want to implement them in my .net website and college project

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.