delight-im / PHP-Auth

Authentication for PHP. Simple, lightweight and secure.
MIT License
1.08k stars 234 forks source link

Compatibility with Redis for User Sessions #288

Open surrealzerg opened 1 year ago

surrealzerg commented 1 year ago

Is this compatible? So far I'm unable to get it working. Redis is installed and PHP is configured for user sessions. This is confirmed working using below snippet. Each time you send a request with a given PHPSESSID, the counter increments by one.

<php start tag session_start(); if (!isset($_SESSION['counter'])) { $_SESSION['counter'] = 0; } $_SESSION['counter']++; echo "Page views: " . $_SESSION['counter']; php end tag>

After clearing all cache in the browser, I login to the app. The below call to auth->login does not throw an exception, so it seems like that is still working.

$auth->login($_POST['email'], $_POST['password']);

In the HTTP response, I do not see a new cookie being set. Normally a new cookie is set post auth.

Then I visit an authenticated page.

The below code runs, and basically the user is never being shown as logged in. I also notice a new cookie being set, which doesn't seem normal. if ($auth->isLoggedIn()) {

I'm currently going through this link to try to resolve this: https://github.com/delight-im/PHP-Cookie#reading-and-writing-session-data