I am struggling with one issue for past few days. For my web application, cookies are used to recognize the machine. If proper cookies are not passed with the request, then the application will go through the second factor authentication(ie user has to enter OTP to login).
Only on iPhone and iPad, users are being asked to enter the OTP every times. I can see that cookies are created on iPhone/iPad, but it is not being send to server with the subsequent requests. This behavior is only if we closes and re-open the safari browser. If I did not close Safari, then cookies are being passed without any issues and application is working as expected.
We do not have this issue in Android/MacOS/Windows OS.
If any one have any idea, please help me.
NOTE: We are using secure HttpOnly persistent cookies. The expiration of the cookie is one year.
Cookie creation code is as follows
private void CreateCookie(HttpResponseBase aobjResponse, string astrCookieKey, string astrCookieValue, DateTime adtCookieExpiry) {
HttpCookie lobjCookie = new HttpCookie(astrCookieKey)
{
Expires = adtCookieExpiry,
Value = astrCookieValue,
HttpOnly = true,
};
if (aobjResponse.Cookies.Get(astrCookieKey) != null)
{
aobjResponse.Cookies.Remove(astrCookieKey);
}
aobjResponse.Cookies.Add(lobjCookie);
}