Jump to content
xisto Community
Sign in to follow this  
iGuest

Logout link without a using a database Multiple Admin Login (php)

Recommended Posts

Logout link without a using a databaseMultiple Admin Login (php)

Is it possible to add a logout link to that file you have above once you login? I used a login without a database and want to add a logout on the page to have someone logout of that page.

-reply by Tavares Hanks

 

Share this post


Link to post
Share on other sites

I don't understand what you mean. You can make someone 'logout' from your system with a few lines. But creating a login without values has any sense?

Share this post


Link to post
Share on other sites

Though we don't have a file above us (that is accessible), every session is just that—a session. If you're using cookies or PHP's built-in session management (which requires a cookie anyway), all you have to do is destroy the session when you send a user to the relative page (i.e. the "logout" page). Concerning the way PHP handles sessions, sessions are "destroyed" the moment the user closes the browser. Cookies are a bit different depending on their lifespan. Normally if you don't provide how long the cookie should remain valid, it gets destroyed upon closing the browser. To destroy a cookie, just give it a date that already passed, like yesterday.

Share this post


Link to post
Share on other sites

I think it is possible like here is the login_logout.php

//make a variable to store user defaults, since it is admin i think one password will be enough $password="yourpasswordhere"; // or if you have more passwords $password=array("jim"=>"pass","etc"=>"etc"); //now to assign a var to user name $admin="adminPassword"; //admin login name here you can get it via form with the $_POST['adminLoginName'] variable or you just can leave it here. if($admin===$password['jim']){ setcookie("admin",$admin,time()+3600); } echo <a href="login_logout.php?value=logout" /> if($_GET["value"]==="logout") { setcookie("admin",$admin,time()-3600); //redirect or whatsoever }

I hope you get what i was trying to say here, use $_GET global variable to logout the user.

Share this post


Link to post
Share on other sites
<?phpsession_start();if(isset($_REQUEST['logout'])) { //index.php  //for a form button//or// if($_REQUEST['logout'] = yes) { //index.php?logout=yes$_SESSION['username']  = 0;$_SESSION['password']   = 0;$_SESSION = array();  session_destroy();  header("Location: ./index.php"); exit;  }?><!DOCTYPE....<html.......

the session_destroy(); //destroy all the session from the site who launch it

Share this post


Link to post
Share on other sites
How to logout when window is closedLogout link without a using a database

Dear Sir/Madam,

I am facing a problem for logout. How to solve it issue on my website. When user is click on logout button  properly than user logout but when user directly closed window than user can't logout.One more problem facing when user closed directly window than ,I have not logout time how to calculate Login duration. 

-question by pankaj kumar

Share this post


Link to post
Share on other sites

gradirei uno script con un logout senza database dove posso chiudere la pagina e tornare alla indexENGLISH TRANSLATION==================I would like a script with a database where I can log out without closing the page and return to the index

Edited by moderator
Translated from Italian to English (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.