Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Cookie doesnCookie doesn't drop
Previous
 
Next
New Post
3/6/2008 10:27 AM
 

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?

 
New Post
3/6/2008 10:06 PM
 

1. You need to add the cookie to the HttpResponse, not the HttpRequest - that is, . . .      Response.Cookies.Add(cookie)
2. If you are creating a persistant cookie (saved on the client's hard disk), you need to set its Expires property.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
3/7/2008 8:16 AM
 

Thank you for your response.

I have tried adding the cookie to both the response and the request; moreover, I have also experimented with changing cookie expiration and none of that works in my deployed environment.

The code in the previous post does work locally but the deployed version just appears to ignore any of the code dealing with the cookie.

 

 

 
New Post
3/17/2008 10:41 AM
 

Any other thoughts are appreciated.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Cookie doesnCookie doesn't drop


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out