<?php
/**
 * [LJCMS] (C)2012-2099 LJdev,Inc.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2013.11.19
*/

class XSession {
	
	
	public static function set($key, $value='') {
		if (!session_id()) self::start();
		if (!is_array($key)) {
			$_SESSION[$key] = trim($value);
		} else {
			foreach ($key as $k => $v) $_SESSION[$k] = $v;
		}
		return true;
	}
	
	
	public static function get($key) {
		if (!session_id()) self::start();
		return (isset($_SESSION[$key])) ? XFilter::filterBadChar(trim($_SESSION[$key])) : NULL;
	}
	
	
	public static function del($key) {
		if (!session_id()) self::start();
		if (is_array($key)) {
			foreach ($key as $k){
				if (isset($_SESSION[$k])) unset($_SESSION[$k]);
			}
		} else {
			if (isset($_SESSION[$key])) unset($_SESSION[$key]);
		}
		return true;
	}
	
	
	public static function clear() {
		if (!session_id()) self::start();
		session_destroy();
		$_SESSION = array();
	}
	
	
	private static function start() {
		session_start();
	}
	
}?>
