I am using a PHP script ( http://www.mpdolan.com/login_redirect.htm ) to secure some pages on our Intranet, and I am looking to do the following:
- On all non-secured pages, offer a place to enter the username/password
- On all secured pages, offer the username that is logged in, and a logout link.
Basically what I am looking for is some code that would check for a session, and if a session does not exist - display the login prompts. If a session does exist - display the username and logout link.
The code that is placed at the top of each page that is secured is this (if this helps):
<?php
//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
session_start();
require('C:\Websites\custcare\www\auth\config.php');
require('C:\Websites\custcare\www\auth\functions.php');
//this is group name or username of the group or person that you wish to allow access to
// - please be advise that the Administrators Groups has access to all pages.
if (allow_access(Administrators) != "yes")
{
include ('C:\Websites\custcare\www\noauth.php');
exit;
}
?>