You do not need SSL to use sessions.
Use the code below to "logout." When you use the back button after logging out, you should not have access any longer.
PHP Code:
session_start();
$_SESSION = array(); // or just unset the session variable you are using to control access unset($_SESSION['username']);
session_destroy();
setcookie("PHPSESSID","",time()-3600,"/");
NOTE!! This is very important. Whenever testing code that uses cookies or sessoins, always "Clear Private Data" from your browser in between testing different code. In Firefox it is under TOOLS, Clear Private Data.
To answer your question about querying your db on every page visit, no, you don't have to do this. Once you have authenticated a user and set a session variable to identify them, you can just test for the presence of this session variable when deciding to allow or disallow access to certain pages.
Also, I really don't understand what session_unset() does. PHP.net says "The session_unset() function frees all session variables currently registered. " I don't know what they mean by "frees."
Bookmarks