How to make apple-mobile-web-application not to lose a session?

I have a web application.

<meta name="apple-mobile-web-app-capable" content="yes"> 

I put it there.

I am adding to the main screen.

However, I understand that I always need to log in again after closing the web application.

How do I save a session?

+6
source share
2 answers

There is a simple answer, but so far I have not been able to find a link to it in the official Apple documentation.

The trick is this:

 // Start or resume session session_start(); // Extend cookie life time by an amount of your liking $cookieLifetime = 365 * 24 * 60 * 60; // A year in seconds setcookie(session_name(),session_id(),time()+$cookieLifetime); 

If you extend the lifetime of your session cookie like this, Safari will stick to the session cookie and even allow session sharing between the β€œhome screen of the installed” version of your web application and regular visits via safari.

For a more detailed discussion, take a look at my answer to this question:

Maintain PHP session in web application on iPhone

+1
source

I use a static class and a static variable, such as a dictionary (string, object) to store data when I have to access an external application. If you use FormAuthentication, you will notice

 User.Identity.IsAuthenticated = true 

but the session does not exist. you can use "User.Identity.Name" as the key to get the data in the dictionary.

This works in ASP.Net MVC3

-2
source

Source: https://habr.com/ru/post/912648/


All Articles