<?php

	class Session{


		function __construct(){}

		public function set($name, $value, $time = null, $path = "/"){

			if($time != null){
				$cookie = setcookie($name, $value, $time, $path);
			}else{
				$cookie = setcookie($name, $value, time() + (3600 * 24), $path);
			}
			
			return ($cookie) ? true : false;

		}

		public function get($key = false){
			if($key == false){
				return json_decode(json_encode($_COOKIE));
			}else{
				return isset($_COOKIE[$key]) ? $_COOKIE[$key] : false;
			}
		}

		public function rem($name, $path = "/"){
			$c = setcookie($name, "deleted", time() - 1, $path) ? true : false;
			return $c;
		}

		public function clean(){
			$stop = null;
			foreach ($_COOKIE as $key => $value) {
				$stop = $this->rem($key) ? true : false;
			}
			return $stop;
		}

		public function destroy(){
			return $this->clean();
		}

	}