Regarding clear history on click of logout button in phonegap using cordova 2.7.0

1,678 views
Skip to first unread message

newbie in phonegap

unread,
Jun 18, 2013, 5:56:13 AM6/18/13
to phon...@googlegroups.com
hy is there any method or line of code to exactly remove all history as i have "logout" button in my app clicking on loggedout buttoon its exactly log out the current user and page changes to "login page " but when i reached to login page and trying to hit "device BACK button" it go back to previous page   which is wrong . the application should not move back once he is loggedout so how can i overcome into this problem  kindly suggest any code to resolve this issue?


here is the code of "loggedout" button :

 $('#logoutButton').off("click").on("click", function () {
        $("#pass").val("");
        window.localStorage.setItem("userid", null);
       
      $.mobile.changePage("#login",null,true,true);
       
    
       

    });

Asna .Ahamed

unread,
Sep 20, 2013, 4:14:20 AM9/20/13
to phon...@googlegroups.com
hi,
 window.localStorage.setItem("userid", null) does not save data to null but saves as a string.Try this:
window.localStorage.clear();



Teodor Sandu

unread,
May 6, 2015, 2:54:51 AM5/6/15
to phon...@googlegroups.com, erumhan...@gmail.com
Basically you can use this:

window.history.go(-(history.length - 1));
window.location.replace('your new url');

the trick is on the first line you go back to the first page in the history, then location.replace() makes sure that one is forgotten as well. Or you can use other navigation means after the first line, as you wish.
Reply all
Reply to author
Forward
0 new messages