ios - Preserving cookies in UIWebView? -


so have uiwebview in app, has php session inside it. under impression these cookies kept long user has app open.

but whats happening user filling out form, locking phone while or switching in out , app. reason cookie missing , session gets reset , have restart.

is there doing wrong?

or there way save cookies after every page load, restore them every time user views app?

if else stumbles across when trying fix themselves, opted fix using javascript on webpage.

first include in base html file, or use php file put in every page on site:(since cant use php headers inside js file.)

<script>     function get_sid(){         return '<?php echo session_id(); ?>';     }     function get_session_name(){         return '<?php echo session_name(); ?>';     } </script> 

then add code 1 of base js files:

<script>    function setcookie(cname, cvalue, exdays) {        var d = new date();        d.settime(d.gettime() + (exdays*24*60*60*1000));        var expires = "expires="+ d.toutcstring();        document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";    }    function refresh_cookie(){        setcookie(get_session_name(), get_sid(), 10000);    } </script> 

hope helps else.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -