I have make an API REST with a connection and disconnect functions. this use the $_SESSION
of PHP to save the session.
This work but wen I connect to the API with sim800l the $_SESSION
is not used, I think the sim800l don't support cookies.
tested on sim800l :
AT+SAPBR=3,1,"APN","free"
OK
AT+SAPBR=1,1
OK
AT+SAPBR=2,1
+SAPBR: 1,1,"10.112.215.42"
OK
AT+HTTPINIT
OK
AT+HTTPPARA="CID",1
OK
AT+HTTPPARA="URL","http://naviwatt.fr/api/setup/mail/a@a.a/*****"
OK
AT+HTTPACTION=0
OK
AT+HTTPREAD
OK
+HTTPACTION: 0,200,11
AT+HTTPREAD
+HTTPREAD: 11
{"level":0}
OK
the return function
/**
* show the level of the connection
* 0 if not connected
* 1 if connected as a boat
* 2 fi connected as a user
*/
public function level() {
header('Content-Type: application/json');
//check if somone is connected
if (isset($_SESSION['loged'])){
$res = array("level" => $_SESSION['loged']);
} else {
$res = array("level" => 0);
}
//send datas
http_response_code(200);
echo json_encode($res);
}
the log part
if ($pass === $userDao->findByMail($id)->getPassword()){
$_SESSION['loged'] = 2;
$_SESSION['user'] = $userDao->findByMail($id);
$_SESSION['boats'] = $boatDAO->findByOwner($id);
} else {
http_response_code(417);
}
this send me a level: 0 as if is not connected but when i test that on Insomnia or Firefox is ok (level 2)