Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

laravel can be use session login? #1

Open
mouyong opened this issue Oct 21, 2022 · 8 comments
Open

laravel can be use session login? #1

mouyong opened this issue Oct 21, 2022 · 8 comments

Comments

@mouyong
Copy link
Contributor

mouyong commented Oct 21, 2022

No description provided.

@joanhey
Copy link
Owner

joanhey commented Oct 21, 2022

Not in Symfony demo.

We are fixing it.

@joanhey
Copy link
Owner

joanhey commented Oct 21, 2022

I'm testing with Laravel Orchid admin, and it's working.
But still testing and fixing the session.

@joanhey
Copy link
Owner

joanhey commented Oct 23, 2022

Fixed in Symfony and Laravel.

@joanhey joanhey closed this as completed Oct 26, 2022
@mouyong
Copy link
Contributor Author

mouyong commented Dec 14, 2022

good job. maybe we can close project laravel-octane-workerman

@mouyong
Copy link
Contributor Author

mouyong commented Dec 14, 2022

#10

@joanhey
Copy link
Owner

joanhey commented Dec 14, 2022

Why create a lib for only 1 framework, when we can create one (Adapterman) that we can use with almost any framework or app.

Only one lib to maintain, for all the frameworks.

@joanhey
Copy link
Owner

joanhey commented Dec 16, 2022

After more checking, work but not correctly.
It's nothing about Adapterman-Workerman.

I'm now trying to fix it. From the Laravel side.
Laravel session, don't use Symfony session that use the normal $_SESSION from PHP or Workerman.

So we'll need to add 2 lines of code for clean the session, in any new request.

@joanhey joanhey reopened this Jan 2, 2023
@joanhey
Copy link
Owner

joanhey commented Jan 2, 2023

From @493226876

OK, thank you for telling me. I always thought that it was a problem where I set up the session. The session has always been repeated. It was originally a mechanism problem. If you have any trouble, please let me know. Thank you

How do you set up the session and auth in Laravel, will be a problem with any worker mode: adapterman, laravel-swoole, Octane, ....

You can't do that, in any worker mode:

namespace App\Http\Controllers;
class TestController extends Controller
{
    protected $userId;
    public function __construct()
    {
        // Wrong usage: Since the controller is only constructed once and then resident in memory, $userId will only be assigned once, and subsequent requests will be misread before requesting $userId
        $this->userId = session('userId');
    }
    public function testAction()
    {
        // read $this->userId;
    }
}

Corect:

namespace App\Http\Controllers;

class TestController extends Controller
{
    protected function getUserId()
    {
        return session('userId');
    }
    public function testAction()
    {
        // call $this->getUserId() to read $userId
    }
}

This week, I'll try with Shared Nothing mode, that for sure will work. But the performance will be in the middle of php-fpm and worker mode.

The problem is from the Laravel side. And we are talking with Laravel devs to clean the session and auth in each request, but from the Laravel side.
We will release the solution.

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

No branches or pull requests

2 participants