What does formsauthentication.setauthcookie do
OK Paste as. Treat my content as plain text, not as HTML. Existing Members Sign in to your account. This email is in use.
Do you need your password? Submit your solution! When answering a question please: Read the question carefully. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid. Related Questions. GetUser is null. Those will prevent the user from being logged in immediately, and cause Membership.
GetUser to return null, because the user isn't currently logged in. That should get your current code working. SetAuthCookie sets a browser cookie to initiate the user's session. It's what keeps the user logged in each time a page is posted to the server. It should be based on whether the user checked the "Remember me" checkbox on your Login form. It isn't available on the CreateUserWizard form by default, but you can add a checkbox for it in your template, if you like.
If you don't want to have the user logged in automatically, remove the FormsAuthentication. You can still set add the user to the appropriate role when the user is created without needing to log them in:.
After you create the user, you want them to be logged in right away, correct? If thats the case, you drop the auth cookie that is used by asp. The "false" means that its not persistent equivalent to "Remember me? As to why your user is NULL, I would suggest placing a breakpoint right before that GetUser call and querying your user data store to see if its really there. FormsCookieName, cookiestr ; if cookiepersist ck. Expiration; ck.
The content you requested has been removed. Ask a question. Quick access. Search related threads. Remove From My Forums. Answered by:. Creates an authentication ticket for the supplied user name and adds it to the cookies collection of the response, using the supplied cookie path, or using the URL if you are using cookieless authentication.
The forms-authentication ticket supplies forms-authentication information to the next request made by the browser. With forms authentication, you can use the SetAuthCookie method when you want to authenticate a user but still retain control of the navigation with redirects. Feedback will be sent to Microsoft: By pressing the submit button, your feedback will be used to improve Microsoft products and services.
Privacy policy.