[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

08/11/2008 at 03:10AM PDT, ID: 23637359
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

ASP.Net persistent cookie not working

Asked by senior_internet in Programming for ASP.NET, C# Programming Language, WebApplications

Tags: Asp.Net 2, C#

Hi all,

We are using a standard Asp.net Login control to authenticate users in a web
application. We have allowed the 'remember me' checkbox to be displayed. We
have set the the cookie timeout  (in the forms element of the web.config) to
be 525600 (1 year). The cookie seems to be working initially but after a
certain amount of time (a day or two, it seems to vary), the application
stops remembering us and prompts us to log in again. The strange thing is
that the cookie still exists on the client machine and has an expiry date of
a year from now so why would the application not be recognising it? I thought it might be the machine key changing that was stopping the cookie from being decoded properly so I manually enetered a machine key into the web.config. Unfortunately that made no difference.

I'm running on IIS version 6 using Asp.net v2.0.

Here's the entire authentication section of the web.config

  <authentication mode="Forms">
       <forms name=".ASPXAUTH"
                   protection="All"
                   timeout="525600"
                   path="/"
                   requireSSL="false"
                   slidingExpiration="true"
                   cookieless="UseDeviceProfile"
                   loginUrl="~/UserAccount/Login.aspx"
defaultUrl="~/Default.aspx"/>
  </authentication>

Here's the section of the web.config that sets the machine key (which seems to make no difference)

      <system.web>
            <machineKey validationKey="106DF81D159AD13D9...........154F064EE22EF779E845C"            decryptionKey="0D8DACE284231159C78AB6937480.......FFD0A8D8"
                  validation="SHA1"
                  decryption="AES" />

Here's the login control converted to a template:

    <asp:Login ID="login1" runat="server">
        <LayoutTemplate>
           <div class="list_form">
                <asp:Label ID="UserNameLabel" runat="server"
                                  AssociatedControlID="UserName">
                    <span>User Name:</span>
                    <asp:TextBox ID="UserName" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="UserNameRequired"
runat="server"
                                                                        ControlToValidate="UserName"
                                                                        ErrorMessage="User
Name is required."
                                                                        ToolTip="User
Name is required."
                                                                        ValidationGroup="login"
                                                                        Display="Dynamic">*</asp:RequiredFieldValidator>
                </asp:Label>
                <div class="clear"></div>
                <asp:Label ID="PasswordLabel" runat="server"
                                  AssociatedControlID="Password">
                    <span>Password:</span>
                    <asp:TextBox ID="Password" runat="server"
TextMode="Password"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="PasswordRequired"
runat="server"
                                                                ControlToValidate="Password"
                                                                ErrorMessage="Password
is required."
                                                                ToolTip="Password
is required."
                                                                ValidationGroup="login"
                                                                Display="Dynamic">*</asp:RequiredFieldValidator>
                </asp:Label>

                <div class="clear"></div>
                <asp:Label ID="Label1" runat="server" AssociatedControlID="RememberMe">
                    <span>Remember me</span>
                    <asp:CheckBox ID="RememberMe" runat="server" />
                </asp:Label>

                <asp:Literal ID="FailureText" runat="server"
EnableViewState="False"></asp:Literal>
                <div class="buttons">
                    <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="login" />
                </div>
           </div>
      </LayoutTemplate>
    </asp:Login>

And here's a summary of the cookie content as displayed by firefox even when the site is asking me to log in.

Name      .ASPXAUTH
Value      60BCF4E7E052FE454EC......7AF74
Host      our.website.co.uk
Path      /
Secure      No
Expires      Fri, 12 Sep 2009 10:03:16 GMT

Is there anything I could be missing here that would make the application ignore this cookie?

Many Thanks,

Chris.
[+][-]08/19/08 06:00 AM, ID: 22259308

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/26/08 01:16 AM, ID: 22312534

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, C# Programming Language, WebApplications
Tags: Asp.Net 2, C#
Sign Up Now!
Solution Provided By: senior_internet
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20091028-EE-VQP-85 / EE_QW_2_20070628