Maintaining a PHP session on an iPhone web app -


i've created web app on iphone. can open , log in no problem, whenever return app has forgotten previous session , have re-enter username , password.

there have been few other questions this, answers haven't helped me solve problem because i'm not sure put php provided.

this best answer i've found: maintain php session in web app on iphone

in answer, wilbo baggins (https://stackoverflow.com/users/346440/wilbo-baggins) provides following code:

// start or resume session session_start();   // extend cookie life time amount of liking $cookielifetime = 365 * 24 * 60 * 60; // year in seconds setcookie(session_name(),session_id(),time()+$cookielifetime); 

i entered code between <?php , ?> tags in website's header, hasn't solved issue. i'm guessing i'm putting in wrong place, i'm looking guidance explain should putting it.

thanks.

--

bump: there out there can me solve issue or, @ least, knows how can in touch wilbo baggins (https://stackoverflow.com/users/346440/wilbo-baggins)?

in login.php, add following code when login information correct:

session_start();  //your code here  if(strpos(strtolower($_server['http_user_agent']),"apple")) //to prevent cookies non-apple devices {     $cookielifetime = 365 * 24 * 60 * 60; // year in seconds     setcookie("ses_id",session_id(),time()+$cookielifetime); } 

then, in every other *.php want session_id restored, add following line before session_start():

if($_cookie['ses_id']){     session_id($_cookie['ses_id']); } session_start(); 

in logout.php, add following code:

session_start(); $cookielifetime = 365 * 24 * 60 * 60; // year in seconds setcookie("ses_id","",time()-$cookielifetime); //set lifetime negative autodelete cookie session_destroy(); 

hope helps.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -