Location: PHPKode > projects > chillyCMS > chillyCMS/core/session.frontend.include.php
<?php
//#################################################################################################
//	Session Management for the frontend
//#################################################################################################
//	chillyCMS - Content Management System
//	Copyright (C) 2008
//	Stefanie Wiegand <hide@address.com> & Johannes Cox <hide@address.com>
//	
//	This program is licensed under the GPL 3.0 license. For more information see LICENSE.txt.
//#################################################################################################
defined('DOIT') or die('Restricted access');

require_once("frontendpage.class.php");

$page = new Frontendpage();
session_start();

if(isset($_POST["action"]) && $_POST["action"]=='logout') { destroy_existing_session(); }
//Get user from session
if (isset($_SESSION["user"])) {
	$myuser = $_SESSION["user"];
	$mysession = new Session($myuser->user,false,"frontend");
//Get user from login
} else if (isset($_POST["name"])) {
	$mysession = new Session($_POST["name"],hash("sha512", $_POST["pw"]),"frontend");
	$myuser = $mysession->user;
	if ($mysession->valid) {
		//Increment Login counter and set last logintime
		$useruid=intval($mysession->user->uid);
		$page->query("update system_users set lastlogin=now(),logins=logins+1 where uid=$useruid");
	}
//set empty
} else {
	$mysession = array();
	$myuser = array();
}
//someone has logged in
if (!empty($mysession)) {
	//load user language and overwrite system language
	if ($mysession->user->language!="") {
		$sitelanguage=$settings["language"];
		$page->language=$mysession->user->language;
	}
	$is_logged=true;
	$is_admin=in_array(1,$mysession->user->gids);
	$is_user=(in_array(2,$mysession->user->gids) or $is_admin);
//just a visitor
} else {
	$is_logged=$is_admin=$is_user=false;
}
?>
Return current item: chillyCMS