Location: PHPKode > projects > Cronus > cronus-1.2.0rc2/includes/session.inc.php
<?php
// include mysql config info
require_once("includes/config.inc.php");

// custom sessions for mysql support
require_once("includes/sess_h.inc.php");

$m_host	= $GLOBALS['config']['mysql']['host']; // MySQL Host
$m_user	= $GLOBALS['config']['mysql']['user']; //MySQL User
$m_pass	= $GLOBALS['config']['mysql']['password']; //MySQL Pass
$m_db	= $GLOBALS['config']['mysql']['database']; //MySQL Database

session_cache_limiter('private');
$cache_limiter = session_cache_limiter();

/* set the cache expire to 30 minutes */
session_cache_expire(10);
$cache_expire = session_cache_expire();

$link = mysql_connect($m_host,$m_user,$m_pass);
if (!$link) {
   die('Could not connect: ' . mysql_error());
}

mysql_select_db($m_db) or die("MySQL error, unable to select database");

// is there already a session going?
if(!isset($_SESSION['currentuser']['userid'])) {
   $query = "SELECT * FROM Users WHERE UserName='".$_REQUEST["username"]."' AND PassWord=PASSWORD('".$_REQUEST["password2"]."')";
   $result = mysql_query($query, $link) or die( "MySQL error: ".mysql_error() );
   $num_rows = mysql_num_rows( $result );

   if( $num_rows < 1 ) { // invalid log/pass combo
      session_destroy();
      mysql_free_result($result);
      session_write_close();
      header('Location: '.$GLOBALS['config']['baseurl'].'/login.php?e=1');
      exit();
   } else {
      // user is valid so grab some basic info about the user for later use
      $_SESSION['currentuser']['userid']	= mysql_result($result,0,"UserId");
      $_SESSION['currentuser']['username']	= mysql_result($result,0,"UserName");
      $_SESSION['currentuser']['fname']		= mysql_result($result,0,"FirstName");
      $_SESSION['currentuser']['lname']		= mysql_result($result,0,"LastName");
      $_SESSION['currentuser']['user_admin']	= mysql_result($result,0,"Admin");
      $_SESSION['currentuser']['job_title']	= mysql_result($result,0,"JobTitle");
      $_SESSION['currentuser']['email']		= mysql_result($result,0,"Email");

      mysql_free_result( $result );
   }
}

if($_GET["do"] == "logout") { // page.php?do=logout
   session_unset();
   session_destroy();
   header('Location: '.$GLOBALS['config']['baseurl'].'/login.php?e=2');
   exit();
} 

?>
Return current item: Cronus