django-sessions

Django SESSION_COOKIE_DOMAIN

I'm seeing something mysterious with the SESSION_COOKIE_DOMAIN setting in django. Normally, when I have this set to ".mydomain.net" it works fine. But occasionally cookies don't seem to be being set, because when I log in, I'm not remembered in the session and I become AnonymousUser when I get to the next page. In these circumstances, ...

Django middleware to determine user's group in a session

I have an app that uses django.contrib.auth but makes no use of Django's built-in permissions system. Instead, views have the @login_required decorator and then check which group the user belongs to, and follow different branches of code execution within the view depending on the group. A user can belong to only one group. Checking for...

Django Session Persistent but Losing Data

Hello everyone, I have been working for hours trying to understand the following problem: I have a user send an Ajax request to dynamically send a form and record that the number of forms to read on submission has increased. Toward this end I use request.session['editing_foo'] = { 'prefix_of_form_elements' : pkey } so that I can associa...

Django, SESSION_COOKIE_DOMAIN with multiple domains.

In Django, I have SESSION_COOKIE_DOMAIN set to my domain name. But I would actually like to run the same site with two different domain names. With SESSION_COOKIE_DOMAIN set, only the named domain allows the user to login. Is it possible to allow both domains to login? ...

Django, delete all cookie

Hello, I want to delete all cookies for the user under my domain name. I know logout() method removes the session,but it seems like some of my apps are generating afew more cookies that needs to be cleansed. How can I achieve this? ![alt text][1] ...

django set_expiry behaving strangely

Hi, I have an app on a UK based server with server time set to GMT The app should be set to Paris time so my settings include TIME_ZONE = 'Europe/Paris' I have sessions saving every request: SESSION_SAVE_EVERY_REQUEST = True For the most part I want the session time to be the default 2 weeks. However when people want to book an...

Django, relying on sessions

Hello, Less or more I am building my site heavly on sessions(especially for redirecting users etc), I am curious if this a dangerous practice. What would be the rough percentage of users who have disabled their cookie saving with their browsers ? I am open to any suggestions :) Thanks ...

Problem with authentication from different domains using Django sessions.

Hi all, I am developing a bookmarklet which essentially adds a toolbar to a web page user is currently looking at. To use it, user needs to be logged in. To login user clicks on 'Singin' which displays a standard form containing Username, Password etc fields. When user successfully logs in they may chose to navigate to a different web-...

How do I properly unit test a Django session?

The behavior of Django sessions changes between "standard" views code and test code, making it unclear how test code is written for sessions. Googling this yields two relevant discussions about this issue: Easier manipulation of sessions by test client test.Client.session.save() raises error for anonymous users I'm confused because b...

access django session from a decorator

I have a decorator that I use for my views @valid_session from django.http import Http404 def valid_session(the_func): """ function to check if the user has a valid session """ def _decorated(*args, **kwargs): if ## check if username is in the request.session: raise Http404('not logged in.') else: return...

How to share a session with a php application.

I have a django blog project and a chat in PHP. I need to share the id of the user logged in django ( request.user.id ) with the chat in PHP. Is this possible ? ...

In django : how to renew expiry date for current session ?

I have a user logged in. How can i extend/renew expiry date of session received from the request ? Thanks in advance! ...

AttributeError: 'WSGIRequest' object has no attribute 'session'

Hello, I keep getting this error at random times and whenever I touch the django.wsgi file, it gets fixed only to happen again after a few hours. I'm lost as to what to do. my middleware_classes is as follows: MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', ...

Django: Managing Session Variables to manage the browser back button

I am creating a web based Mock test paper, which needs to be fairly secure. The needs are Each question can be attempted and answered just once. All are multiple Choice questions Once a question is answered and the submit pressed, then that session must expire, and the same question must not appear either through back button or some o...

How to deal with temporary storage of uploaded files

In my django application I have a multi step registration, with few conditional parameters. Because of this I figured out to store data from forms in session. Unfortunatelly sessions serialize data using pickle, which doesn't support file serialization and causes PicklingError: Can't pickle <type 'cStringIO.StringO'>: attribute lookup cS...

Using sessions in Django

I'm using sessions in Django to store login user information as well as some other information. I've been reading through the Django session website and still have a few questions. From the Django website: By default, Django stores sessions in your database (using the model django.contrib.sessions.models.Session). Though this ...