Replies: 3 comments
-
|
Implementation: |
Beta Was this translation helpful? Give feedback.
-
|
Creating a session when the user has no intention of logging in is a waste of resources. |
Beta Was this translation helpful? Give feedback.
-
|
I think what you're probably running into is calling You can check |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
getSessionalways runscreateSessionwhenreadDatacannot find a corresponding entry.Another method that does not run
createSessionin such a case is required when you develop a member-only application and expose its login page to the public.If
createSessionis called too many times (e.g. by DoS attack), the performance of a database can be degraded, especially when you use only RDBMS and do not combine it with KVS NoSQL (e.g. Redis/Valkey).vs
react-router/packages/react-router/lib/server-runtime/sessions.ts
Lines 266 to 270 in 255ac96
The current
getSessionwill perform a wasteful operation even if an user has no merit to receive a session data.vs
As you might notice, it returns just
nullwithout creating new one when no entry.This will not be a breaking change unless you use third party session libraries. However, an author of a third party session library have to modify their library to implement this method. Unfortunately JavaScript/TypeScript cannot provide default method implementations in an interface unlike Java or C#.
Beta Was this translation helpful? Give feedback.
All reactions