2021-12-05 12:56:23 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<?php
|
|
|
|
/*
|
2021-12-05 13:04:53 +00:00
|
|
|
* Copyright (C) 2021 Eichehome
|
2021-12-05 12:56:23 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
2022-01-23 11:17:55 +00:00
|
|
|
* @author Eichehome
|
2021-12-05 12:56:23 +00:00
|
|
|
*/
|
|
|
|
class Session
|
|
|
|
{
|
|
|
|
/**
|
2022-01-23 11:17:55 +00:00
|
|
|
* Konstruktor (Startet eine Session)
|
2021-12-05 12:56:23 +00:00
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-01-23 11:17:55 +00:00
|
|
|
* Setzt einen Wert für einen Schlüssel im Session-Array. Falls kein Wert angegeben, wird der Wert gelöscht
|
|
|
|
* @param string $key Schlüssel
|
2021-12-05 12:56:23 +00:00
|
|
|
* @param string $value Wert
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function set(String $key, String $value = "")
|
|
|
|
{
|
|
|
|
return $_SESSION[$key] = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-01-23 11:17:55 +00:00
|
|
|
* Gibt den Wert für einen Schlüssel im Session-Array zurück
|
|
|
|
* @param string $key Schlüssel
|
2021-12-05 12:56:23 +00:00
|
|
|
* @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();
|
|
|
|
}
|
|
|
|
}
|