Questions tagged [django-sessions]

For questions related to Django's session mechanism.

Django provides full support for anonymous sessions. The session framework lets you store and retrieve arbitrary data on a per-site-visitor basis. It stores data on the server side and abstracts the sending and receiving of cookies. Cookies contain a session ID – not the data itself (unless you’re using the cookie based backend or a custom backend).

Reference: https://docs.djangoproject.com/en/stable/topics/http/sessions/

490 questions
0
votes
0 answers

Django admin expiring session all the time

I have a Django project that works perfectly locally, but I can't use the admin page in the server because the page is reloaded every time I click in the links and the user credentials are re-requested. I cleaned cache, cookies and the session data…
msampaio
  • 3,394
  • 6
  • 33
  • 53
0
votes
1 answer

request.session.get('last_visit') yields None all the time

I am recently into session and cookies. I comprehend session and cookies well in theory but i have one issue in understanding the code of session. It is about getting the last_visit by the user. The code is from the tangowithdjango.com def…
pythonBeginner
  • 781
  • 2
  • 12
  • 27
0
votes
0 answers

Looking for potential problems by setting session cookie for every user

For the business-logic reason, I need to set a sessionid cookie for the each site visitor, even if there are no actual data stored for this session. It can be possible by setting SESSION_SAVE_EVERY_REQUEST to True and by overriding…
coldmind
  • 5,167
  • 2
  • 22
  • 22
0
votes
1 answer

remove item from django-carton with Ajax

This is driving me crazy. I am building an ecommerce app, with the cart in Django-carton. When I add an item to the cart, I can get the item's id from the context into the store, and pass it into my Ajax call and to the view when a customer adds…
fstopzero
  • 1,073
  • 2
  • 10
  • 24
0
votes
0 answers

session variables in django

In my django project I have the following portion of HTML:
{% csrf_token %}
sarra
  • 23
  • 5
0
votes
1 answer

Django : Session data not being saved

Extremely new to web development, trying to pass user inputs in a form from one view to another using the session. Session seems to reset after the HttpResponseRedirect in my "get_single_input" view, as I can retreive the "local_test" from the…
user3234810
  • 482
  • 2
  • 5
  • 18
0
votes
1 answer

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…
ramdaz
  • 1,761
  • 1
  • 20
  • 43
0
votes
1 answer

Can Django migrate sessions from the "cache" to "cached_db" engine?

I'm currently running a Django application with SESSION_ENGINE configured as django.contrib.sessions.backends.cache. I'd like to change this to django.contrib.sessions.backends.cached_db to gain persistence. Can I make this change without destroying…
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
0
votes
0 answers

Django session strange behavior

Currently using django 1.7. I'm using a file based session storage and have request.session.modified set to True. In a simple DB record creation, i store the row id in the session like so: request.session['rid'] = xyz request.session.modified =…
BoCode
  • 847
  • 4
  • 17
  • 33
0
votes
0 answers

Django: saving session objects after returning the response

I am creating large session objects in my app. When I use cached_db backend, the response time gets significantly longer because the session objects are written to the DB before the response is returned to the user. Is there a way to save the…
ahmohamed
  • 2,920
  • 20
  • 35
0
votes
1 answer

Django session IDs for anonymous sessions

I see that a random (but not necessarily unique) session_key is generated for new sessions and this is stored in whichever session type you're using (cache, db, cookie). The two queries I have are: Is a new session_key generated for all sessions,…
jvc26
  • 6,363
  • 6
  • 46
  • 75
0
votes
1 answer

Delete session key when browser is refreshed ( Django )

How do I delete session when the browser is refreshed by the user? I do know, the following deletes the session key. del request.session['session_key'] Edit: I am trying to propagate user entered value across multiple forms in different views, and…
hlkstuv_23900
  • 864
  • 20
  • 34
0
votes
1 answer

How to use sessions in Django

# In mypage.html

{{ p }}

# In the views.py file p = 1 def mypage(request): global p my_dictionary = { "p" : p, } if…
PiccolMan
  • 4,854
  • 12
  • 35
  • 53
0
votes
1 answer

Django default behaviour of session - Session get expired after closing browser

I read Django tutorial but found nothing related to never expiring session. Requirement - User should logged out only if he/she initiate by clicking on logout. How can I solve this issue? My django project settings related to session -…
0
votes
0 answers

can we return variable from the python decoretor?

I have used function for checking session key in django (it need to code). def sessioncheck(unikey): from django.contrib.sessions.models import Session try: session_obj = Session.objects.get(pk=unikey) userinfo =…
Gtr_py
  • 3,511
  • 1
  • 12
  • 13