Monday 2 April 2012

Safari Issues with FormsAuthentication

So today, one of the customer's that we have had noted that his browser (on the iPhone) was losing his login everytime he closed it. Whilst fighting the urge to make rude comments about his choice of browser/os/life, I decided to see where the issue lay today.

So the long and short of it is this: Safari loves to lose Session Data if it is not persisted. So the way we were forwarding from logon :

FormsAuthentication.RedirectFromLoginPage("Username", false);


Simply did not cut the mustard! We needed to rethink so we put:

FormsAuthentication.RedirectFromLoginPage("Username", true);



Weren't we awesome? Well, whilst this did fix the problem of Safari forgetting everything like your aunty noris, one of our devs came up with the great idea that maybe we should have an ebay-esque, "log me in all day" feature.

This required a little reading and the result was the idea from stack overflow (as most of my google searches seem to end).

Now we choose the timout (default of 30 mins) based on the user selection. Much better! One thing I did note was that the code will default to the timeout if left in the web.config, therefore, keep the tag but remove the timout (if there!) from the tag.


Now, as long as our users have cookies enabled (resist the matrix runs on xp quote) and you are away. Of course, there may be more elegant solutions, however, we got it working!

No comments:

Post a Comment