I've just started a new django project, didn't change settings to much. And my admin session cookie is expired in seconds (I've checked in the DB as well.)
I've tried setting this:
SESSION_COOKIE_AGE = 1209600
which is the default setting, but it does not work. Why this is happening?
I must say it didn't occur in other django project I have.
Related
When I close a tab or browser and then I run the application again opening the browser again, the previous session remains active. I tried SESSION_EXPIRE_AT_BROWSER_CLOSE = True in settings.py file in the project directory as per the Django documentation. Nothing works. Even the existing solutions in stackoverflow does not work. Is there any way to clear the session on a browser or tab close in Django?
I looked through some web sources, and the reason could be that your session already existed before you set up SESSION_EXPIRE_AT_BROWSER_CLOSE. Try to run
python manage.py clearsessions
In a Django website I use memcached to save a variable in cache.
After some minutes, if I refresh the page, the variable is lost.
I am in develop mode using runserver.
Any ideas?
Cache keys are expired after some time. If you don't explicitly pass timeout to cache.set, Django will use defaul, which it retrieves from settings. If you didn't specify default timeout yourself, Django will use its own default.
I'm working on a django project and since a few days django keeps logging me of after I change a source file.
The expire date in the cookies and in the database show that theres still 1 month left.
Even after making the change the session cookie is the same as in the database but I have to login again. and after logging in both sessionids (database and browser) change.
I'm using django 1.8.5
edit:
some session related settings:
SESSION_EXPIRE_AT_BROWSER_CLOSE False
SESSION_COOKIE_HTTPONLY True
SESSION_COOKIE_DOMAIN None
SESSION_SAVE_EVERY_REQUEST False
SESSION_COOKIE_SECURE False
edit2:
Just to be a bit more clear: After changing some source file (python files, templates work just fine) the server will reload (if I use --noreload, I have to do it manually to get the changes), after that everyone is logged out.
edit3:
CACHES {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}}
SESSION_ENGINE 'django.contrib.sessions.backends.db'
Django has a SESSION_ENGINE setting that controls how the session information is stored on the server. One of the options is django.contrib.sessions.backends.cache, which stores session information only in cache memory.
Now, there's a certain cache backend - django.core.cache.backends.locmem.LocMemCache -, which stores information in the local python memory (for more info see CACHES). This cache backend is a typical choice for development, and of course resets each time the server is reloaded.
Using these two settings together would perfectly explain the situation you describe. Hope this helps!
I am new to Django. created a super user using manage.py createsuperuser. Can log into the site in Firefox, every time, but never in Chrome or IE, the login popup keeps popping up. The only time it worked was when I used manage.py clearsessions. Not working anymore. Cleaned the session by going into sqlite still no success.
Hmm... cookie settings? Django doesn't use cookie-based sessions by default, but that login form probably does have a CSRF cookie in it. If it keeps rejecting your login over and over on different browsers, it could be because you have those browsers set not to take the cookie.
I've recently switched server/database and am having trouble getting the google and facebook social apps to log in. I have the keys set up correctly and when hitting both facebook and google it successfully creates a django user and a social account, but it does not log the user in. Notably, it sends the user to LOGIN_REDIRECT_URL correctly.
When attempting to sign in with an existing user after it has already been created, it also does not log in, but also sends to LOGIN_REDIRECT_URL correctly.
I can't figure out why it is behaving this way in the new environment, and am struggling on finding where to look. My best guess is that somewhere the pre_social_login signal or the social_account_added signal? Any ideas?
EDIT:
Also worth noting, I switched from python 3.4 to python 2.7, but django remained 1.6.5
Turned out I was missing the allauth.account.auth_backends.AuthenticationBackend in the settings AUTHENTICATION_BACKENDS when i did the migrate.