Jon Romero
Jon Romero

Reputation: 4090

Reading session/cookies from WSGI

Is there any way to retrieve sessions right from the WSGI (using a middleware)? I know that it depends on your SessionMiddleware but I wonder if there are hints to figure out when a session is created.

Upvotes: 2

Views: 1900

Answers (2)

Danny Navarro
Danny Navarro

Reputation: 2753

With Beaker (a common WSGI middleware for sessions) you can know whether a session has been accessed or not.

Upvotes: 1

Lennart Regebro
Lennart Regebro

Reputation: 172239

It's created by the session middle ware. There are no such thing as sessions in http itself. It's usually done by setting a cookie, but can be done in other ways too.

So to answer the question of "when" it is created this is typically done by the session middleware, when it gets a request that does not already have a session cookie in it.

Upvotes: 2

Related Questions