Cleanup and documentation of common_ensure_session

- Remove redundant branch
- Remove error suppression of session_start()
This commit is contained in:
brunoccast 2019-06-04 01:02:46 +01:00 committed by Diogo Cordeiro
parent a1af5562de
commit 061e7891e9

View File

@ -275,12 +275,12 @@ function common_have_session()
return (0 != strcmp(session_id(), '')); return (0 != strcmp(session_id(), ''));
} }
/**
* Make sure session is started and handled by
* the correct handler.
*/
function common_ensure_session() function common_ensure_session()
{ {
$c = null;
if (array_key_exists(session_name(), $_COOKIE)) {
$c = $_COOKIE[session_name()];
}
if (!common_have_session()) { if (!common_have_session()) {
if (common_config('sessions', 'handle')) { if (common_config('sessions', 'handle')) {
session_set_save_handler(new InternalSessionHandler(), true); session_set_save_handler(new InternalSessionHandler(), true);
@ -293,7 +293,7 @@ function common_ensure_session()
if (isset($id)) { if (isset($id)) {
session_id($id); session_id($id);
} }
@session_start(); session_start();
if (!isset($_SESSION['started'])) { if (!isset($_SESSION['started'])) {
$_SESSION['started'] = time(); $_SESSION['started'] = time();
if (!empty($id)) { if (!empty($id)) {