I'm trying to get a cookie to drop upon a user logging into DNN. I put the following code in:
Private Sub UserAuthenticated(ByVal sender As Object, ByVal e As UserAuthenticatedEventArgs)
LoginStatus = e.LoginStatus
'Check the Login Status
Select Case LoginStatus
Case UserLoginStatus.LOGIN_USERNOTAPPROVED
Select Case e.Message
Case "EnterCode"
AddModuleMessage(e.Message, ModuleMessageType.YellowWarning, True)
Case "InvalidCode", "UserNotAuthorized"
AddModuleMessage(e.Message, ModuleMessageType.RedError, True)
Case Else
AddLocalizedModuleMessage(e.Message, ModuleMessageType.RedError, True)
End Select
Case UserLoginStatus.LOGIN_USERLOCKEDOUT
AddModuleMessage("UserLockedOut", ModuleMessageType.RedError, True)
' notify administrator about account lockout ( possible hack attempt )
Dim Custom As New ArrayList
Custom.Add(e.UserToken)
Mail.SendMail(PortalSettings.Email, PortalSettings.Email, "", _
Localization.GetSystemMessage(PortalSettings, "EMAIL_USER_LOCKOUT_SUBJECT", Localization.GlobalResourceFile, Custom), _
Localization.GetSystemMessage(PortalSettings, "EMAIL_USER_LOCKOUT_BODY", Localization.GlobalResourceFile, Custom), _
"", "", "", "", "", "")
Case UserLoginStatus.LOGIN_FAILURE
'A Login Failure can mean one of two things:
' 1 - User was authenticated by the Authentication System but is not "affiliated" with a DNN Account
' 2 - User was not authenticated
If e.Authenticated Then
PageNo = 1
AuthenticationType = e.AuthenticationType
AutoRegister = e.AutoRegister
ProfileProperties = e.Profile
UserToken = e.UserToken
ShowPanel()
Else
If String.IsNullOrEmpty(e.Message) Then
AddModuleMessage("LoginFailed", ModuleMessageType.RedError, True)
Else
Me.AddLocalizedModuleMessage(e.Message, ModuleMessageType.RedError, True)
End If
End If
Case Else
If e.User IsNot Nothing Then
'First update the profile (if any properties have been passed)
AuthenticationType = e.AuthenticationType
ProfileProperties = e.Profile
Dim cookie As HttpCookie = New HttpCookie("loginCookie") /****************************Cookie is created and added to request ******************/
cookie.Value = txtUsername.Text
Request.Cookies.Add(cookie)
UpdateProfile(e.User, True)
ValidateUser(e.User, False)
End If
End Select
End Sub
This works if I use it on the localhost, but when I access the DNN deployment from the server the cookie is not present.
Any ideas on what needs to be done to get this to implement correctly for the deployment?