djangosnippets.org: Latest snippets tagged with 'sessions'https://djangosnippets.org/tags/sessions/2010-05-07T02:56:15-05:00Middleware for using HttpOnly session cookie (including monkey patching for support for Python &lt;2.6)2010-05-07T02:56:15-05:00chrjhttps://djangosnippets.org/snippets/2012/<p>A middleware to set the httponly flag on the session cookie. Including monkey patching for support for Python &lt;2.6.</p>
Freely redistributableTest if sessions are working2010-03-01T02:21:18-06:00jpichttps://djangosnippets.org/snippets/1946/<p>I wasn't sure if my setup supported sessions properly. This view helped me make sure.
</p>
<p>Usage: fill the inputs with text and make sure that these values traverse a couple of requests. If it doesn't work then maybe the session backend you've set is broken?
</p>
Freely redistributableUsing another memcached for sessions2008-11-15T09:01:00-06:00dipankarsarkarhttps://djangosnippets.org/snippets/1191/<p>This solves the problem of losing sessions data when you restart memcached. So you use a different memcached instance for sessions which you rarely restart.</p>
<p>Use the above code and add the following to you settings.py</p>
<pre><code>SESSION_ENGINE = "kwippyproject.session_backend"
SESSION_CACHE = 'memcached://127.0.0.1:11200/'
</code></pre>
<p>(Above assumes that ...</p>
Freely redistributableStrictAuthentication - Auto log-out inactive users2008-10-02T12:36:01-05:00yeagohttps://djangosnippets.org/snippets/1105/<p>This dead-simple piece of middleware adds a terrific security feature to django authentication. Currently, users who's accounts are de-activated still may have a cookie and a login session. This middleware destroys that session on their next request.
</p>
<p>Simply add this class into a middleware.py and add it to ...</p>
Freely redistributableUpload, Progressbar with sessions2008-08-22T07:21:00-05:00revolunethttps://djangosnippets.org/snippets/999/<p>This script is an adaptation from http://www.djangosnippets.org/snippets/678/ . Here, it doesnt use the cache middleware but relies on sessions.</p>
<p>The script set a session cookie to identify the upload and track it to make it available for a progress bar like this one : http://www.djangosnippets ...</p>
Freely redistributableRefreshSessionMiddleware2008-08-06T08:10:04-05:00jcasseehttps://djangosnippets.org/snippets/945/<p>This middleware refreshes the session before it expires to avoid dropping the session of an active (but read-only) user. By default it refreshes the session after half the expiry time has elapsed.</p>
<p>(This middleware does nothing for browser-length sessions.)</p>
Freely redistributableClear session data on login and logout 2008-04-03T10:57:41-05:00jb0thttps://djangosnippets.org/snippets/681/<p>This was born as a result of the fact that session data is shared across logins on a single browser. If you login as user1 and session data is stored, then login as user2 the same session data will be available to your application. Please see the ticket who's ...</p>
Freely redistributable