You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: working-with-session/index.md
+6-4
Original file line number
Diff line number
Diff line change
@@ -229,7 +229,7 @@ There is two mechanism where session initialization and serialization can be don
229
229
230
230
When using dispatcher for working with session, session is initialized after request object is created and serialized to storage before response is sent to client over the wire. So session is always applied globally through out application.
231
231
232
-
When using middeware for working with session, session is initialized when middlewareis attached globally to application middleware list or per route. Using middleware when working with session is more flexible. For example you may want to apply session management only for certain routes and not other.
232
+
When using middleware for working with session, session is initialized when middleware, which is attached globally to application middleware list or per route, is executed. Using middleware when working with session is more flexible. For example you may want to apply session management only for certain routes and not other.
233
233
234
234
## Create dispatcher instance which support session
235
235
@@ -259,24 +259,26 @@ container.add(
259
259
Please read [Dispatcher](/dispatcher) for more information or you may want to get information about [how to create Fano web application project with session using Fano CLI](/scaffolding-with-fano-cli#add-session-support).
260
260
261
261
## Session middleware
262
-
Since v1.10.0, Fano Framework provides session middleware `TSessionMiddleware` which can be use as alternative to using dispatcher when working with session. `TSessionMiddlewareFactory` class is factory class for this middleware.
262
+
Since v1.10.0, Fano Framework provides session middleware `TSessionMiddleware` which can be use, as an alternative to using dispatcher when working with session. `TSessionMiddlewareFactory` class is factory class for this middleware.
263
263
264
264
```
265
265
container.add(
266
266
'my.session.middleware',
267
267
TSessionMiddlewareFactory.create(
268
-
container.get('sessionManager') as ISessionManager
268
+
container['sessionManager'] as ISessionManager
269
269
)
270
270
);
271
271
```
272
272
273
-
To apply session middleware globally so that session is initialized and serialized through out application. If you attach middleware as first middleware to run globally, it is similar compare to when using dispatcher.
273
+
To apply session middleware globally, so that session is initialized and serialized through out application.
274
274
275
275
```
276
276
(container['appMiddlewares'] as IMiddlewareList)
277
277
.add(container['my.session.middleware'] as IMiddleware);
278
278
```
279
279
280
+
It is similar to using dispatcher.
281
+
280
282
To apply session middleware so that session is only initialized and serialized when certain routes is accessed, attach middleware to route.
0 commit comments