title: iPad/iPhone Chrome - Auth Cookie not setting over jquery post (ajax) - MVC 3
body: <p>I'm having trouble with Chrome on the iPad/iPhone with what I thought was a simple enough task and works on Chrome Desktop (Mac &amp; PC) and Safari on iPad/iPhone.</p>
  
  <p>I have the following jquery on my page:</p>
  
  <p>$("#login-login-button").click(function () {
          var username = $("#Username").val();
          var password = $("#Password").val();</p>
  
  <pre><code>    $("#login-loading-icon").show();
  
      $.post("/login", { username: username, password: password }, function (data, response) {
          if (response == "success") {
              if (data.IsValid) {
                  window.location.href = "/profile";
              }
              else {
                  $("#login-error-message").html(data.ErrorMessage);
                  $("#login-loading-icon").hide();
              }
          }
          else {
              alert("An error occurred, please try again.");
          }
      });
  });
  </code></pre>
  
  <p>And the Controller Action is code looks like this:</p>
  
  <pre><code>[HttpPost]
  public JsonResult Index(string username, string password)
  {
          AjaxResponseModel ajaxResponseModel = new AjaxResponseModel();
  
          User user = UserDAL.Select(username, Hash.MD5(password));
  
          if (user != null)
          {
              if (!user.IsVerified.Value)
              {
                  ajaxResponseModel.AddErrorMessage("Account not verified.");
              }
              else if (!user.IsActive.Value)
              {
                  ajaxResponseModel.AddErrorMessage("Your account is not active.");
              }
              else
              {
                  FormsAuthentication.SetAuthCookie(username, false);
              }
          }
          else
          {
              ajaxResponseModel.AddErrorMessage("Login details incorrect.");
          }
  
          return Json(ajaxResponseModel);
      }
  </code></pre>
  
  <p>I've tried setting the Auth Cookie via a non-ajax request but it's not working either.</p>
  
  <p><strong>And I've discovered that on the iPad/iPhone if I use the "Request Desktop Site" in the Chrome menu the problem disappears however there is no concept of mobile/desktop on my site at this point i.e. what Chrome gets the first time should be the Desktop site...</strong></p>