Last active
January 27, 2016 19:57
-
-
Save edvaldoszy/8dae6f0b9c99230fd3a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Sys; | |
class Sessao | |
{ | |
public function __construct() { | |
if (!isset($_SESSION)) | |
session_start(); | |
} | |
/** | |
* @param string $nome | |
* @return boolean | |
*/ | |
public function existe($nome) { | |
return isset($_SESSION[$nome]); | |
} | |
/** | |
* @param string $nome | |
* @param mixed $valor | |
* @return void | |
*/ | |
public function gravar($nome, $valor) { | |
$_SESSION[$nome] = $valor; | |
} | |
/** | |
* @param string $nome | |
* @return mixed | |
*/ | |
public function ler($nome) { | |
if ($this->existe($nome)) | |
return $_SESSION[$nome]; | |
return null; | |
} | |
/** | |
* @param string $nome | |
* @return void | |
*/ | |
public function excluir($nome) { | |
if ($this->existe($nome)) | |
unset($_SESSION[$nome]); | |
} | |
/** | |
* @return boolean | |
*/ | |
public function destruir() { | |
if (isset($_SESSION)) | |
return session_destroy(); | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment