.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sharon Maxwell

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How To Auto Login into the WebSite

Posted By: Santosh     Posted Date: February 22, 2010    Points:2   Category :ASP.Net
can any body plz tell me how to Auto login a WebSite.
means when i run the application,it Automatically login into the website.


Author: Praveen          Accepted Answer   
Posted Date: February 22, 2010     Points: 10   

Hello Santosh,

Use cookies to save username and password and while loading the web page (Page_Load event) check the cookies first whether it exist or not if cookies exist than take the value from this cookies and validate.

And in successful authentication redirect to whatever page you want.

Author: Lalij Mer             
Posted Date: February 22, 2010     Points: 5   

Use this code sample to using the ASP.Net Membership and FormsAuthentication an easy way to do auto-login is the following code

string userEmail = "abc_xyz@gmail.com";
string password = "thepassword";
if (Membership.ValidateUser(userEmail, password))
FormsAuthentication.SetAuthCookie(userEmail, true);

show here another details


Please Check my answer if you help....
Thank You...

Author: Santosh             
Posted Date: February 22, 2010     Points: 5   

hi praven
can u plz send me code.


Author: Santosh             
Posted Date: February 22, 2010     Points: 5   

hi lalit
ur code is not working.


Author: Amit Mehra             
Posted Date: February 22, 2010     Points: 5   

HI Santosh,

To save the user name and password in the cookies you can try like this

HttpCookie myCookie = new HttpCookie("myCookie"); //Create the instance of HttpCookie class

myCookie.Values.Add("username", "MyUserName"); // Add Key and its value to Cookies

myCookie.Values.Add("password", "MyPassword"); // add Another key and value.

To Retrive the value from the Cookies try like this

HttpCookie cookie = Request.Cookies.Get("myCookie");

string UserName = cookie.Values["username"];

string Password = cookie.Values["password"];

Hope this will help you.

Please "Mark As Answer " if this post help you.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend