Click here to Skip to main content
15,918,668 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi, my application redirects from the login page, user name and passwords are called from the data base.Here i have another 3 or 4 page that are not opened with out a login permissions, these pages are also be loaded only right user name and password. if i am trying to execute any of these pages without login it automatically redirects to the login page. all the pages are opened only for right user name and password.i want to use session to store the user name and passwords. can any one help me how to write code for this.
Posted

Why don't you study this project Login Control in ASP.NET 3.5[^]. It looks like something you could use.

Best Regards,

—MRB
 
Share this answer
 
Comments
thatraja 9-Aug-11 13:24pm    
Right, 5!
fjdiewornncalwe 9-Aug-11 13:52pm    
Absolutely.
After login, store the login values(UserID, UserName) in Session.
C#
Session["UserID"] = "user1";

In next page Check the session value in page_load & if it fails then redirect to login page.
C#
if(Session["UserID"] != null)
{
  Response.Redirect("login.aspx");
}

After logout Abandon the Session & redirect to login page.
 
Share this answer
 
v2
Comments
fjdiewornncalwe 9-Aug-11 13:53pm    
Might be good to note that he shouldn't be storing the password itself. A token of some kind is ok, but for the love of god, not a plain text password...
thatraja 9-Aug-11 14:00pm    
:) Yep OP is a beginner.
BTW what movie you all went on last weekend?
Member 10556881 17-Feb-14 6:47am    
how to allow user that after login only use other pages with login other pages can not be use
thatraja 17-Feb-14 6:57am    
Implement the same code on all pages(better way, write this on master page). If session is null then it'll redirect to login page.

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