guys
using php i want to logout means user can only enter from login page if he click on any href or link it display enter your user name and password in login page
log out
Moderator: General Moderators
Re: log out
Well, you'll need to check if the user is logged in on each page.
If not, redirect them to the login page.
If not, redirect them to the login page.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: log out
+1 what jackpf said. Use sessions for that. Then on the logout page you destroy the session with session_destroy().
Re: log out
if you use sessions,
if you use cookies:
etc.
(see here for info on how to expire a cookie: http://www.tech-recipes.com/rx/1501/php ... er_cookie/)
you may want to redirect using meta refresh
(you should also put a link to the destination page for those with no meta redirect support.)
or php header
afterwards.
Code: Select all
session_destroy();Code: Select all
setcookie("username", "", time()-3600);
setcookie("password", "", time()-3600);(see here for info on how to expire a cookie: http://www.tech-recipes.com/rx/1501/php ... er_cookie/)
you may want to redirect using meta refresh
Code: Select all
echo '<meta http-equiv="refresh" content="6;URL=http://www.yoursite.com/index.php" /> You are now being logged out.';
or php header
Code: Select all
header('Location: index.php');