Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am new to the .net so please tell me how to login user by using session in asp.net.
please tell me complete procedure.
Thank you.
Posted

I would recommend you use FormsAuthentication instead of Session. However, to use Session you need a page that will validate the user and then you can store their username in a Session variable. Then on every single page you'll need to check to make sure that Session variable is filled in and if it is not you'll have to redirect them to the login page. You can do this using a BasePage class that all of your pages inherit from; however, it is a lot easier to let ASP.Net manage it for you using FormsAuthentication
 
Share this answer
 
Comments
ali_heidari_ 22-Mar-13 15:52pm    
good suggest! FormsAuthentication is more safe than sessions!
Check below msdn link for formsAuthentication example
Explained: Forms Authentication in ASP.NET 2.0[^]
Also Check below link
Forms Authentication in ASP.NET with C#: Advance[^]
Check Video on
Using ASP.NET Forms Authentication [^]
 
Share this answer
 
v3
Comments
ali_heidari_ 22-Mar-13 15:54pm    
questin is about sessions!
for example you wanna access to admin.aspx
first check session("user_id")
if it is "" then redirect it to login.aspx
 
Share this answer
 
after user authenticating in the login.aspx , save user information into sessions ...
something like this :
C#
Session["username"]=username; // username is variable that contain username value

or maybe you save a dataset into sessions .
then you cane use this session through the website.
somethin like this :
C#
username=Session["username"].ToString(); // username is variable that contain username value
 
Share this answer
 

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