0.9.0 - the ZapV version updated to current php standards. Brave search used, while Bing and Google search api are deprecated
This commit is contained in:
parent
3d4298fe8b
commit
4ddaddda3d
31 changed files with 1778 additions and 1 deletions
63
utils/Session.class.php
Executable file
63
utils/Session.class.php
Executable file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* Basic session wrapper / adapter
|
||||
*/
|
||||
class Session {
|
||||
/**
|
||||
* Start session
|
||||
* @param string $name name of session
|
||||
* @param string $path override ini directive session.save_path
|
||||
*/
|
||||
public static function start($name, $path = null) {
|
||||
$started = false;
|
||||
if (!$started) {
|
||||
session_name($name);
|
||||
if ($path !== null) {
|
||||
session_save_path($path);
|
||||
}
|
||||
session_start();
|
||||
$started = true;
|
||||
}
|
||||
Session::setCacheControl('private');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache control
|
||||
* @param string $value sets the http cache control value
|
||||
*/
|
||||
public static function setCacheControl($value) {
|
||||
header('Cache-Control: ' . $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* reset session array
|
||||
*/
|
||||
public static function reset() {
|
||||
$_SESSION = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete client's cookie
|
||||
*/
|
||||
public static function deleteCookie() {
|
||||
if (isset($_COOKIE[session_name()])) {
|
||||
setcookie(session_name(), '', time()-42000, '/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy session completely
|
||||
* @return boolean
|
||||
*/
|
||||
public static function destroy() {
|
||||
self::reset();
|
||||
self::deleteCookie();
|
||||
|
||||
if (session_destroy()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue