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.0Trying to Check for CookiesTrying to Check for Cookies
Previous
 
Next
New Post
10/10/2007 12:28 PM
 

I am trying to implement a modification on my DNN install that will allow me to tell the end user that their cookies are blocked.  I have come up with something, but it is reading the cookie no matter if cookies are blocked or not.  :(  At first, I was trying with my local install, but realizing that my local install is "trusted", I put this on a deployed install and it still reads the cookies when they are disabled.

Here is what I have done in the Page_Load event of the Signin.ascx.vb file:

            '********************************************************************************************'
            ' BEGIN DNN MODIFICATION
            '--------------------------------------------------------------------------------------------'
            MyNamespace.Utilities.Cookies.SetCookie("PageLoad", "True")
            MyNamespace.Common.Mail.SendMailToAdmin("PageLoad Cookie Equals...", String.Format("PageLoad = {0}", MyNamespace.Utilities.Cookies.GetCookieValue("PageLoad")))
            If String.IsNullOrEmpty(MyNamespace.Utilities.Cookies.GetCookieValue("PageLoad")) Then
                DotNetNuke.UI.Skins.Skin.AddPageMessage(Me.Page, _
                    Localization.GetString("ErrorMessage.CookiesDisabled.Header", Me.LocalResourceFile), _
                    Localization.GetString("ErrorMessage.CookiesDisabled.Text", Me.LocalResourceFile), _
                    ModuleMessageType.RedError)
            Else
                If Not String.Equals(MyNamespace.Utilities.Cookies.GetCookieValue("PageLoad"), "True") Then
                    DotNetNuke.UI.Skins.Skin.AddPageMessage(Me.Page, _
                        Localization.GetString("ErrorMessage.CookiesDisabled.Header", Me.LocalResourceFile), _
                        Localization.GetString("ErrorMessage.CookiesDisabled.Text", Me.LocalResourceFile), _
                        ModuleMessageType.RedError)
                End If
            End If
            MyNamespace.Utilities.Cookies.SetCookie("PageLoad", "False")
            '--------------------------------------------------------------------------------------------'
            ' END DNN MODIFICATION
            '********************************************************************************************'

I have also tried setting the cookie on the home page first (Default.aspx.vb), and then checking it here (signin.ascx.vb), but the cookie is read no matter what I do.  :( 

The MyNamespace.Utilities.Cookies methods are as follows:

        Public Shared Sub SetCookie(ByVal key As String, ByVal Value As String)
            'Encode Part
            key = HttpContext.Current.Server.UrlEncode(key)
            Value = HttpContext.Current.Server.UrlEncode(Value)
            Dim cookie As HttpCookie
            cookie = New HttpCookie(key, Value)
            SetCookie(cookie)
        End Sub
        Public Shared Function GetCookie(ByVal key As String) As HttpCookie
            'encode key for retrieval
            key = HttpContext.Current.Server.UrlEncode(key)
            Return HttpContext.Current.Request.Cookies.Get(key)
        End Function
        Public Shared Function GetCookieValue(ByVal key As String) As String
            Try
                'don't encode key for retrieval here
                'done in the GetCookie function
                'get value 
                Dim value As String
                value = GetCookie(key).Value
                'decode stored value
                value = HttpContext.Current.Server.UrlDecode(value)
                Return value
            Catch ex As Exception
                Return String.Empty
            End Try
        End Function

Can anyone tell me why my cookie value is read even when I disable cookies?  Does anyone have a better way of doing this?


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Trying to Check for CookiesTrying to Check for Cookies


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