<?php
	class SessHandler
	{
		var $_sessVar = array();
		function sessRegister($var)
		{
			$this->_sessVar = $var;
			session_start();
			session_register('user_id');
			session_register('username');
			
			 $_SESSION['sessid'] = $this->_sessVar['user_id'];
			 $_SESSION = $this->_sessVar;
			return $_SESSION;			
		}
		
		function checkLogin()
		{			
			session_start();
			if (is_array($_SESSION) && $_SESSION['user_id'] > 0){
				switch ($_SESSION['access_level']){
					case 0 :
						$_SESSION['access'] = true;
						session_register('access');
						@header('Location: '.ADMIN_DIR);
						break;
					case 1 :
						@header('Location: '.SITE_URL);
						break;
					default :
						@header('Location: '.SITE_URL.'login.php?access=no');
						break;
				}
			}
			else {
				/*$_SESSION['access'] = true;
				session_register('access');
				@header('Location: '.ADMIN_DIR);*/
				@header('Location: '.ADMIN_DIR.'login.php?access=login');
			}
		}
		
		function sessDestroy()
		{                                                 //http://sysfileserver1/silverstarjewelry/admin/
			session_start();
			$_SESSION['sessid'] = '';
			$_SESSION['access'] = '';
			session_unregister('user_id');
			session_unregister('username');
			session_destroy();
			header('Location:'.ADMIN_DIR.'login.php?access=logout');
		}
	}
	$objSessHandler = new SessHandler();
?>