MINT-Projekt/class/Session.php

71 lines
1.6 KiB
PHP

<!DOCTYPE html>
<?php
/*
* Copyright (C) 2018 Christian Brüggen
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Wrapper für eine Session
*
* @author Christian Brüggen
*/
class Session
{
/**
* Konstrucktor
*/
public function __construct()
{
$this->start();
}
/**
* Setzt einen Wert für einen Key im Session-Array
* @param string $key Key
* @param string $value Wert
* @return string
*/
public function set(String $key, String $value = "")
{
return $_SESSION[$key] = $value;
}
/**
* Gibt den Wert für einen Key im Session-Array zurück
* @param string $key Key
* @return string
*/
public function get(String $key)
{
return $_SESSION[$key];
}
/**
* Zerstört eine Session und ihre Werte
*/
public function destroy()
{
session_destroy();
}
/**
* Startet eine Session
*/
public function start()
{
session_start();
}
}