Skip to content

Instantly share code, notes, and snippets.

@edvaldoszy
Last active January 27, 2016 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edvaldoszy/8dae6f0b9c99230fd3a7 to your computer and use it in GitHub Desktop.
Save edvaldoszy/8dae6f0b9c99230fd3a7 to your computer and use it in GitHub Desktop.
<?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