Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

isLoggedIn not persistent #237

Closed
T0mAl3x opened this issue Oct 29, 2020 · 2 comments
Closed

isLoggedIn not persistent #237

T0mAl3x opened this issue Oct 29, 2020 · 2 comments
Labels

Comments

@T0mAl3x
Copy link

T0mAl3x commented Oct 29, 2020

Hello! I'm having problems checking if the user is logged in.
$this->auth->login($username, $password);
if ($this->auth->isLoggedIn())
return [
'status' => 'ok'
];
return 'Something went wrong';

Here the isLoggedIn returns true which is OK. But when I redirect to another page...

public function index() {
  // Check if user is logged in
  // else redirect to LogInPage
  $db = new Database;
  $auth = new \Delight\Auth\Auth(
    $db->getPDO(), null, null, false, 60);
  if (!$auth->isLoggedIn()) {
    redirect('users/#');
  }
  
  editPath(null, "reset");

  $result = $this->pagesModel->sendCommand(123456, "EXPLORE", "/");
  setSendedCmdId($result[0]->ID);
  
  $pathsError = '';
  // if (!$result) {
  //   $pathsError = 'There was a problem when sending the command';
  // }

  $data = [];
 
  $this->view('pages/index', $data);
}

...
In the index method I recreate de auth instance and when I call isLoggedIn() it returns false.

@T0mAl3x T0mAl3x closed this as completed Oct 29, 2020
@T0mAl3x
Copy link
Author

T0mAl3x commented Oct 29, 2020

It worked eventually. I think it was a session desync.

@ocram ocram added the question label Nov 3, 2020
@ocram
Copy link
Contributor

ocram commented Nov 3, 2020

No problem. Thanks for letting us know!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants