-
Notifications
You must be signed in to change notification settings - Fork 75
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
Access Session Data #11
Comments
I have a similar problem, the |
Hi, I have the same problem , does somebody have a solution please ? Thx |
I have come up with a workaround. It involves taking the laravel_session cookie, decrypting it, and then retrieving the session from the session_id. (Note: I'm using the file driver for sessions.) Here's my code: In the EventListener, under onMessage I added:
You can then grab the user_id associated with the session by accessing the 'login_##########' key of this session_array object. You'll have to open up one of the session files to find what this key is, but it should be the same across all sessions. Once you have the user_id, you can just do a User::find() on it, and voila, you have access to your user model. To include the username with the response, you will need to json_decode the $msg variable, and then add a new attribute under $json->client->data. and then re-encode it. Ex.
Hope that helps someone! Took me a lot of beating my head against the wall to come up with this one. |
Nice, Ill try it! :) |
Is there any way to access laravel's Session data from within BrainSocketEventListener.php?
Traditional calls, like Session::get($variable) give me an error indicating that BrainSocketEventListener has no idea what Session:: is.
The text was updated successfully, but these errors were encountered: