7

To authanticate users in Asp.net Membership we can call method

FormsAuthentication.Authenticate(username, password)

how can I do the same job (generate session, cookies and all other staff that Authanticate does) without users password?

I'm trying to login user over facebook connect. User's facebook id is stored within the users data. User should be signed in like a normal user.

Ante
  • 8,567
  • 17
  • 58
  • 70

1 Answers1

11

I think you can use the SetAuthCookie method.

more info here http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.setauthcookie.aspx

John Boker
  • 82,559
  • 17
  • 97
  • 130
  • 1
    ASP.NET MVC 4 Simple Membership WebSecurity Source - see "Login" method: http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/854bcdb520dc#src/WebMatrix.WebData/WebSecurity.cs – Aaron Hoffman Mar 06 '13 at 22:49
  • 2
    that does not work when i ask WebSecurity.CurrentUserName it gives me the previous user.!! – Amir Magdy Jun 04 '14 at 00:52
  • 1
    @AmirMagdy do you find a better solution? Does it still cause the same problem? – Sam Jan 11 '18 at 01:42
  • @Sam yep just do a redirect right after so the cookie is refreshed for the page and it'll work – Amir Magdy Apr 03 '18 at 09:04