title: ASP.NET Forms Authentication Cookie not set in Safari
body: <p>I have a ASP.NET Web Service which exposes a method called DoLogin</p>
  
  <pre><code>[WebService(Namespace = "http://rtns.ism.ec/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [ToolboxItem(false)]    
  [ScriptService]
  public class UserManagerService : WebServiceBase
  {
  
      [WebMethod(EnableSession=true)]
      [ScriptMethod]
      public ResponseBase&lt;bool&gt; DoLogin(LoginCredentials Credentials)
      {
          Credentials.IpAddress = HttpContext.Current.Request.UserHostAddress;
          Credentials.ServerID = Environment.MachineName;
          Credentials.SystemID = WebConfigurationManager.AppSettings["SYSTEM_ID"];
          Credentials.UserAgent = HttpContext.Current.Request.UserAgent;
  
          try
          {
              DataResponse&lt;User&gt; resp = UserManager.LoginUser(Credentials);
  
              if (resp.Code)
              {
                  FormsAuthentication.SetAuthCookie(Credentials.Email, true);
                  HttpContext.Current.Session.Add(Constants.Identifiers.USER_SESSION_INFO_IDENTIFIER, resp.Data);
              }
              return resp;
          }
          catch (Exception _ex)
          {
              ISM.Essentials.Business.LogManager.SaveLog(_ex);
              return new ResponseBase&lt;bool&gt; { Message = MessageManager.Instance[Constants.Messages.E_GENERIC_FAILURE, Credentials.CultureID] };
          }
      }
  
  }
  </code></pre>
  
  <p>I have a JQuery client, which makes the call:</p>
  
  <pre><code>function loginSubmitHandler() {
  
      var objeto = {
          Email: $('#txtUser').val(),
          Password: $('#txtPassword').val(),
          CultureID: $('#hddCulture').val()
      };
  
      utils.startAjaxCall('../Services/UserManagerService.asmx/DoLogin', { Credentials: objeto }, function(data) {
  
      if (data.d.Code) {
          window.location.replace('home.aspx');
      }
      else
      {
          utils.alert(locals.Information, locals.Accept, data.d.Message);            
      }
      });
  
      return false;
  }
  </code></pre>
  
  <p>When I log in with icorrect credentials, the alert with the message sent from the server appears. If I give correct credentials, the page is redirected to home.aspx</p>
  
  <p>This code is working 100% fine since the begining in the following browsers:</p>
  
  <ul>
  <li>IE6, 7, 8, 9</li>
  <li>Mozilla</li>
  <li>IE9 Windows Phone</li>
  <li>Android 2.3 Browser</li>
  <li>Safari 5.1 for Windows</li>
  </ul>
  
  <p>I've just got a Mac (first ever) and when I tried to access my website, I noticed an extrange behavior. I give correct login credentials, I'm redirected to home, but the FormsAuthentication mechanism redirects back to the login page. </p>
  
  <p>It seems like the Auth cookie returned back from the server is just ignored.</p>
  
  <p>This is not an issue with cross domain cookies, as I'm calling the web server in the same web application/domain.</p>
  
  <p>Any ideas on how to make Safari for Mac to accept the cookies returned in an Ajax Web Service call?</p>