How can I log a user on automatically once they have been identified with a cookie in C#?
Membership.ValidateUser("membersUsername","membersPassword") will let me know if it's a valid user but it won't log them on.

Recommended Answers

All 4 Replies

Depends how you are implementing your login structure. When a user is logged on, are you not assigning information to a session variable which indicates they are "logged on"?

I'm using the default membership provider that handles that, but I'm starting to think that it might be easier to validate the user and assign the session variable manually. What I am looking for is something like Membership.LoginUser("username", "password") but the default Membership provider does not make it that easy.

I would recommend that you do some additional research before you embark on a certain path. I have found that the asp.net site has very good information about this topic:

http://www.asp.net/web-forms/tutorials/security

Jorge,
Thanks for the response.
I had gone through the tutorials you referenced and think Scott Mitchell is one of the best resources of information I've found. In his tutorials he still uses a login control and the Login_Authenticate method of his control, which he modifies to add some nice features. That still requires the user to be directed to a login page and click the login control to get to the Login_Authenticate method. I've tried calling the method and creating similar ones but can't find the right AuthenticateEventArgs to pass to it.
What I'm trying to do is have a user to go straight to a page that requires a login, identify him via a cookie from his last login, and log him in without him having to do anything else. I have everything done except for being able to log him in. Partly due to some of Scott Mitchell's tutorials I went with the default Membership provider but a simple task of logging someone in has been very elusive.
Regards,
Ed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.