Comments (5)
I'm having a similar issue--unable to save the session when using a socket.io listener
Can read and write:
router.get('/count', ctx => {
var session = ctx.session;
session.count = session.count || 0;
session.count++;
ctx.body = session.count;
})
Can only read:
io.on('test', (ctx, data) => {
console.log('test get count', ctx.session.count)
var session = ctx.session;
session.count = session.count || 0;
session.count++;
})
from generic-session.
Edit: turns out this has a simple fix. The second fetch will work. Still looking for socket.io workaround
Just as a warning for others, it appears that koa-generic-session does not allow modification to session from a fetch call.
browser:
fetch('/count', {
method: 'POST',
headers: {
count: 1,
}
})
fetch('/count', {
method: 'POST',
headers: {
count: 2,
},
credentials: 'include'
})
server:
router.post('/count', (ctx) => {
var session = ctx.session
console.log('sesh1', ctx.session)
session.count = session.count || 0
session.count = session.count + ctx.request.header.count
console.log('sesh2', ctx.session)
ctx.status = 200
});
from generic-session.
im having the same read only issue in websockets while using koa-session
and koa-websocket
. tried switching to generic-session
using a redis store and had the same issue.
@tbenst did you ever find a solution to this?
from generic-session.
@hedgerh haven't tried it yet but this appears to outline a solution: http://stackoverflow.com/questions/26643370/get-user-id-socket-io-passport-koa.
If you do try it, please do post if it works and/or the code, cheers!
Edit: also, if you only need to read this works: LnsooXD/koa-socket-session#1 (comment). May be able to modify this code for writing to session, haven't looked into it yet
from generic-session.
Closed per #94 (comment)
from generic-session.
Related Issues (20)
- Deprecated "maxage"; use "maxAge" instead HOT 4
- cicyle dependecies HOT 4
- run test case error HOT 1
- regenerateSession是不是有问题 HOT 7
- bug of regenerateSession HOT 2
- Store.set - TTL from cookie.maxAge is not set HOT 1
- How use session?
- refresh session error: Cannot read property 'done' of undefined HOT 1
- Ccookie not work in Safari
- koa.sid gets reset when Cache-Control:max-age=0 is sent? HOT 2
- ctx.session this.session ?
- if user disabled the cookie store in client side(browser)
- V2.0是否有BUG?external store取不到值? HOT 1
- sameSite: true by default?
- set session error : Cannot set property name of which has only a getter HOT 5
- Issue with Redis Store and terser HOT 5
- Session never destroyed when set rolling to true
- TypeError: Cannot set property name of which has only a getter HOT 1
- Correct implementation for SessionStore HOT 1
- [fix] Context TS typing is not working HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generic-session.