i have an asp.net mvc4 application, in which i have this class:
public class Internaute {
public int Id { get; set; }
public string Name { get; set; }
public string Login { get; set; }
public string Password { get; set; }
}
then, when a user connect, i get its informations by storing it in a session variable like this:
Session["user"] = myInternaute;
And i used these informations ,for example, like this:
@{
Internaute myInternaute = (Internaute)Session["user"];
string login = myInternaute.Login;
string pwd = myInternaute.Password;
}
I test the autorization of the user to acces by
Internaute myInternaute = (Internaute)Session["user"];
if(myInternaute == null) return RedirectToAction("Index");
So i have these questions:
- Is it a good way to proceed by a session variable?
- Is there another idea to do this, because the session were lost.
- Does this idea have some advantages?
Thanks,