0
I have a Session class where every time I urge her she automatically starts the session.
When in another file I do I destroy the session through a method called doLogout
I see that it automatically deletes my session as expected but creates another automatically without me passing any parameter.
And the one that is created automatically has an input called sidebar worthwhile 1
that I do not know where they come from, for at no time in my code have I declared it.
Class
class sessao{
protected $id_ur;
protected $nvars;
public function __construct($inicia=true){
if($inicia==TRUE){
$this->start();
}
}
public function start(){
session_start();
$this->id_ur = session_id();
$this->setNvars();
}
private function setNvars(){
$this->nvars = sizeof($_SESSION);
}
public function getNvars(){
return $this->nvars;
}
public function setVar($var, $valor){
$_SESSION[$var] = $valor;
$this->setNvars();
}
public function unsetVar($var){
unset($_SESSION[$var]);
$this->setNvars();
}
public function getVar($var){
if(isset($_SESSION[$var])){
return $_SESSION[$var];
}else{
return NULL;
}
}
public function destroy($inicia=false){
session_unset();
session_destroy();
$this->setNvars();
if($inicia==TRUE){
$this->start();
}
}
public function printAll(){
foreach ($_SESSION as $k => $v){
printf("%s = %s<br />", $k, $v);
}
}
}
?>
Function doLogout()
mentioned
public function doLogout(){
$sessao = new sessao();
$sessao->destroy(TRUE);
redireciona('index.php');
}
About you not having set this index I doubt. Do a search in your source code that will surely appear. Now, by chance, you don’t instate that class in the index php. also?
– Bruno Augusto
Yes instancio no index.php por isso é que depois que eu dou doLogout é que ele volta a classe sessão.
– Aron Brivio
Bruno Augusto, thanks for the tip, I went to my source code, alias I had already gone but I had forgotten a folder where I had some includes and there was the error. beginner vacillation. Thank you ;)
– Aron Brivio
Solved, then?
– Bruno Augusto
Yes, solved, thanks for the tip ;)
– Aron Brivio