Posted on: 8/4/2014 5:25:12 PM | Views : 381

Hi :)
In my website i have a users database.
A user can register and login.
I have a class User.cs that whose properties are the properties of the user in the database and that class also have a fill and a save method to fetch and save user to the database.
What i want to do is to store the User object of a loged in user into a session i.e. every time the user fills the login form with a username and a password:
User user = new User(); if(user.Fill(username.Text, password.Text)) { // If such user exists in the database Session["User"] = user; } The problem is that i want the user to stay loged in as long as he doesn't logout by himself(i.e. making the session last forever).
So i figured that i can create a cookie that stores the user ID when he logs in and check in the master page (page_load method):
if(Session["User"] == null) { User user = new U ...

Go to the complete details ...