Sharing session with Socket.io both ways
See original GitHub issueI’ve seen a number of tutorials of how to share an express session with socket.io. However, they all usually show how to SET from express and then GET from within the socket connection. (server)
Is there a way to do this where you can SET from within the socket connection?
io.on('connection', function(socket){
socket.request.session.userdata = mydata;
});
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to use with `express-session` | Socket.IO
There are two ways to share the session context between Express and Socket.IO, depending on your use case:
Read more >How to share sessions with Socket.IO 1.x and Express 4.x?
The solution is surprisingly simple. It's just not very well documented. It is possible to use the express session middleware as a Socket.IO...
Read more >The Importance of Documentation or “How i discovered how to ...
I found myself in this situation quite recently while building a project, i wanted a way to share an Express session with Socket.io...
Read more >Sharing sessions between SocketIO and Express using Redis
In this post I'll explain how to share session data between SocketIO and NodeJS Express framework by storing session data to Redis.
Read more >Socket.io - shared session with Express : r/node - Reddit
socket.on("set-data", function(data) { socket.handshake.session.data = data; socket.handshake.session.save ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Funny, I actually had to read this post to do the opposite. My NodeJs controller /logout was being called but my socket.io middleware kept bringing the user session back to life. Had to get rid of
session.touch.save()
and now everything works great!