Commit acf76cc8 authored by thejoelinux's avatar thejoelinux

ajout sessions sur saas

parent 0460d0e0
......@@ -29,12 +29,14 @@ class session_saas {
session_set_cookie_params($this->life_time);
}
session_start();
return true;
}
public function __destruct() {
if($this->debug) {
trigger_error('session_saas::__destruct called', E_USER_NOTICE);
}
return true;
}
public function open() {
......@@ -60,9 +62,11 @@ class session_saas {
if($this->debug) {
trigger_error('session_saas::read called', E_USER_NOTICE);
}
if($session = json_decode(file_get_contents($GLOBALS["saas_auth_url"].
"?o=saas_sessions&a=read&i=".$id))) {
return base64_decode($session->data);
if($session = json_decode(file_get_contents($GLOBALS["saas_sessions_url"].
"?a=read&i=".$id))) {
if(isset($session->data)) {
return base64_decode($session->data);
}
}
return '';
}
......@@ -74,7 +78,6 @@ class session_saas {
$postdata = http_build_query(
array(
'o' => 'saas_sessions',
'a' => 'write',
'i' => $id,
'data' => base64_encode($data)
......@@ -90,7 +93,10 @@ class session_saas {
);
$context = stream_context_create($opts);
return json_decode(file_get_contents($GLOBALS["saas_auth_url"], false, $context));
if(file_get_contents($GLOBALS["saas_sessions_url"], false, $context)) {
return false;
}
return true;
}
public function destroy($id, $key_only = FALSE) {
......@@ -99,7 +105,6 @@ class session_saas {
}
$postdata = http_build_query(
array(
'o' => 'saas_sessions',
'a' => 'destroy',
'i' => $id
)
......@@ -114,14 +119,21 @@ class session_saas {
);
$context = stream_context_create($opts);
return json_decode(file_get_contents($GLOBALS["saas_auth_url"], false, $context));
if(!file_get_contents($GLOBALS["saas_sessions_url"], false, $context)) {
return false;
}
return true;
}
public function gc($max) {
/*
if($this->debug) {
trigger_error('session_saas::gc called', E_USER_NOTICE);
}
return json_decode(file_get_contents($GLOBALS["saas_auth_url"].
"?o=saas_sessions&a=gc"));
if(!file_get_contents($GLOBALS["saas_sessions_url"]."?a=gc")) {
return false;
}
*/
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment