How to Auto Login a WebSite

Posted by Santosh4u under ASP.NET on 2/22/2010 | Views : 18697 | Status : [Member] | Replies : 14
hi
can any body plz tell me how to Auto login a WebSite.
means when i run the application,it Automatically login into the website.

Regards
Santosh




Responses

Posted by: Vuyiswamb on: 2/22/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
You mean like when you logged into Gmail , next time when you type gmail it does not ask you for password it just log you in. (same Computer) ?



Thank you for posting at Dotnetfunda
[Administrator]

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi2434 on: 2/22/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Place a auth cookie in the client. when login executes, bypass the normal login if auth cookie is found and matches to a valid login.

You must generate and store the authcookie to database of some secure location, so that you can check it to find the original user.

So you are just bypassing the normal userId / password login with Cookie based login. If the cookie data doesnt matches, it will fallback to the normal login again..

:)

www.abhisheksur.com

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhijit Jana on: 2/22/2010 [Member] [MVP] Bronze

Up
0
Down
You are looking for SSO kind of thinks ? Can you please tell me what are the different web application are you using ?


Cheers !
Abhijit

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 2/22/2010 [Member] Starter

Up
0
Down
Guys, I think he is looking for "Remember me next time" kind of stuffs where if he has once logged in and come back after sometime, he will be still logged in.

Santhosh, if this is what you wanted see below code snipppet for your solution, to bring the Login ui, you can use login control that is here http://www.dotnetfunda.com/tutorials/controls/login.aspx

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)

{
bool authenticated = AuthenticateMe(Login1.UserName, Login1.Password, Login1.RememberMeSet);
if (authenticated)
{
FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);
}
}


Read this article for complete solution http://www.dotnetfunda.com/articles/article114.aspx

Thank you.

Regards,
Raja, USA

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhijit Jana on: 2/22/2010 [Member] [MVP] Bronze

Up
0
Down
Raja,

You may correct. But I may think he is looking for SSO ( Single Sign On) , where you are logged in a application and you want to logged in different application with same credentials.

I think, while any one asking any question they should be more clear so that we can answer better :)

Cheers !
Abhijit

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi2434 on: 2/22/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Yes... Also confused with the application and website.

How can signin to an application and automatically signin to website.

It means somehow it needs to connect the client app with the website.

www.abhisheksur.com

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santosh4u on: 2/22/2010 [Member] Bronze

Up
0
Down
ok guys.
i am giving u clear clarification of my Question.

Ex: let us tak example of gmail.
i set my defeult website as gmail in my browser.
when i open the browser, it should automatically login into the gmail without giving any user name and password.

or same like i need the code so that in code itself i ll give the user name or password but when i ll run the application/code, it automatically login into the gmail or any wesite.


Regards and Thanx
Santosh



Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhijit Jana on: 2/22/2010 [Member] [MVP] Bronze

Up
0
Down
Why do you need that ? You can save the user id and password as cookies and then it will logged in automatically. You do not need to write extra code for logging in Gmail.

Cheers !
Abhijit

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santosh4u on: 2/22/2010 [Member] Bronze

Up
0
Down
i m not telling abt gmail.just i gave the ex: like gmail.
when i ll open the browser ,i need to auto login withing touching keyboard.

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi2434 on: 2/22/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Yes... Follow the steps:

From your website, keep a field in a database table where you can store a key for a particular user. Say its Table USERDATA(USERID , USERLASTSKEY)

During the first login, let user give a valid login.

Check from the server side if userid and password matches. Generate a Guid.NewGuid and store it for the current user to USERDATA table.

Also pass the same key to Response.Cookie["authkey"]

Now from Page_Load() of the Login.aspx check if authkey cookie is present. If so, browse the table UserData and check if there is any valid match. If found, redirect to Home.aspx and put all the authentication info from the User tables.
If authkey cookie not found, pass the Loginpage normally.

Does it seems to u fine ?
I recommend not to store sensitive info in Cookie, rather place a AuthKey generated in the server.

:)

www.abhisheksur.com

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 2/24/2010 [Member] Bronze

Up
0
Down
You can use Remember Me functionality of asp.net Login Control C#. For details check

http://forums.asp.net/p/1371816/2870384.aspx

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: RandiR on: 4/18/2010 [Member] Starter

Up
0
Down

can any body plz tell me how to Auto login a WebSite.
means when i run the application,it Automatically login into the website.



I think good solutions have already been posted. As an alternate solution, scripting approch may be useful. Here is a script in biterscripting.


# Start session

isstart "dailylogin" "description" "Mozilla/4.0"
# Connect to the server and get the default login form.
isconnect "dailylogin" "http://www.xxx.yyy"
# Get cookies from the server and put them in header for all future requests.
script "SS_ISCookies.txt" from( "dailylogin" ) to( "dailylogin" )
# Submit the login page - this is at "ACTION=". I will assume it is login.asp.
issubmit "dailylogin" "/login.asp" "login=myloginid" "password=mypassword"

# ...
# DO OTHER STUFF
# ...

# Disconnect and end the session.
isdisconnect "dailylogin"
isend "dailylogin"




This script is in biterscripting.

ASP.NET websites send a session id as a cookie, which is automatically taken care of the SS_ISCookies.txt call in this script. ASP.NET sites also maintain these variables -

__VIEWSTATE, __EVENTVALIDATION, __EVENTTARGET, __EVENTARGUMENT, __LASTFOCUS


You need to extract their values from each response and submit them in subsequent request. So, the issubmit command will look like -


issubmit "dailylogin" "/login.asp" "login=myloginid" "password=mypassword" "__VIEWSTATE=..." "__EVENTVALIDATION=..." etc.



This would get you full access to the web site without touching the keyboard or mouse.


Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhaskara on: 7/28/2011 [Member] Starter | Points: 25

Up
0
Down
You can use Integrated Windows Authentication (IWA) method, which recogonise credentials when you login to your client or server system. Hence it does not prompt you for user credentials for the application which need to use.

Bhaskara

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vinay13mar on: 11/14/2012 [Member] Starter | Points: 25

Up
0
Down

Login to post response