Cookies not working on firefox

Last post 02-28-2007 1:38 PM by waynesellars. 2 replies.

Sort Posts:

  • Cookies not working on firefox

    02-25-2007, 4:40 AM
    • Member
      point Member
    • blain57
    • Member since 02-25-2007, 9:33 AM
    • Posts 2

    Ive been trying to make a forms authentication work for 2 days now. There seems to be a problem with writting the forms authenticate cookie on my firefox browser (it works on ie6).

    my login.aspx.cs code is:

     

    protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie authCookie1 = new HttpCookie("aaaa1", "aaa");
            Response.AppendCookie(authCookie1);
          
            if (IsPostBack)
            {
                String nextPage = null;
                filecloudTableAdapters.UsersTableAdapter checkUserAdapter = new filecloudTableAdapters.UsersTableAdapter();
                filecloud.UsersDataTable checkUser = checkUserAdapter.CheckIfUserExists(username_textbox.Text, password_textbox.Text);
                if (checkUser.Rows.Count > 0)
                {
                    filecloud.UsersRow userRow = (filecloud.UsersRow)checkUser.Rows[0];
                    
                    FormsAuthentication.SetAuthCookie(userRow.user_name, true);
                    FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, userRow.user_name, DateTime.Now, DateTime.Now.AddMinutes(30), RememberMe.Checked, "aaa");
                    string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                    HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);                         
                    Response.AppendCookie(authCookie);
                    HttpCookie authCookie2 = new HttpCookie("aaaa2", "aaa");
                    Response.AppendCookie(authCookie2);
    
                    if (Request.QueryString["ReturnUrl"] != null)
                    {
                        nextPage = Request.QueryString["ReturnUrl"];
                    }
                    else
                    {                    
                        nextPage = "Default.aspx";
                    }                
                    Response.Redirect(nextPage, true);
                    
    
                }
                else
                {
                    error_label.Text = "Puf!";
                }
                
                
            }
    
        }

     

     

    Now the first cookie up there before the postback is working. The second one wont write. I tried with SetAuthCookie and it didnt work at all (not even before the postback)

     

    My web.config auth is as such:

     

     <authentication mode="Forms">
          <forms name="filecloud"
                    loginUrl="login.aspx" cookieless="AutoDetect" domain="localhost"
                    protection="All"
            enableCrossAppRedirects="true"
                    timeout="30"
                    path="/">
          </forms>
        </authentication>
        <authorization>
          <deny users="?" />
          <!-- Deny anonymous user -->
          <allow users="*" />
          <!-- Allow all authenticated users -->
        </authorization>

     

    The weird thing is that last night the whole thing was working. 

     does anyone have any ideas?
     

  • Re: Cookies not working on firefox

    02-25-2007, 10:09 AM
    • Member
      point Member
    • blain57
    • Member since 02-25-2007, 9:33 AM
    • Posts 2

    Never mind, i uploaded it on a server online and it works with firefox and ie. something to do with localhost? maybe the :random port visual studio assigns?

     

     

  • Re: Cookies not working on firefox

    02-28-2007, 1:38 PM
    • Member
      156 point Member
    • waynesellars
    • Member since 09-16-2004, 6:09 AM
    • Posts 34

    I was just looking for an answer for the same thing... if it is like my problem uploading to the production will only work for a little while then it will stop working, just like it does on localhost.  Usually we can get it to work again by completely dumping the FireFox cookies and cache.  Sometimes this happens in ie 6 (hasn't happened to us in 7 yet).

    We also set our project to use a static port, so apparently that does not have anything to do with it.

Page 1 of 1 (3 items)