Reputation: 316
So I'm using jQuery mobile and PHP to log out of my website via this code
To access the logout code you click on the logout button. coded like this
<div data-role="footer" data-id="foo1" data-position="fixed">
<div data-role="navbar" data-iconpos="top">
<ul>
<li><a href="logout.php" data-transition="none" data-icon="delete">Sign Out</a></li>
</ul>
</di>
</div>
this is the logout.php script
session_start();
session_destroy();
header('location: login.php');
It works in logging me out and taking me to login page, but the url is
mysite.com/logout.php
instead of
mysite.com/login.php
It displays the login.php information but the url is wrong. How do I fix that?
Upvotes: 1
Views: 703
Reputation: 74217
When using links to a page outside a mobile framework such as jQuery mobile, you MUST include rel="external">
in the href.
For example:
<a href="logout.php" data-transition="none" data-icon="delete" rel="external">Sign Out</a>
this is extremely important, otherwise it will think you want it to remain in the same page you came in from.
Upvotes: 1
Reputation: 316
I needed to change
<li><a href="logout.php" data-transition="none" data-icon="delete">Sign Out</a></li>
To
<li><a href="logout.php" data-transition="none" data-icon="delete" rel="external">Sign Out</a></li>
someone pointed out that with jquery mobile it thought i wanted to stay in the page so i needed to add rel="external"
i also added die("<meta http-equiv='refresh' content='0;url=login.php'>");
to the script
Both of those fixed the problem
Upvotes: 1
Reputation: 586
Try something like this:
header('Location: login.php');
die();
Is there any error thrown?
BTW: you can also try this:
session_start();
session_destroy();
die("<meta http-equiv='refresh' content='0;url=login.php'>");
Upvotes: 2