5

I have a search view that saves some data in a session for another view:

def search(request):
    ...
    if request.method == 'POST':
        form = SearchForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            melk=data(cd)
            request.session['data'] = melk
            request.session['form'] = form
            return redirect('/result/')
    ...

def result(request):
    ...
    melk_list = request.session['data']
    form = request.session['form']
    ...

When I use Chrome, everything is good. But when I use Firefox, it works fine the first time, but after that each search keeps returning my first result! It seems request.session doesn't change after the first time. I tried to delete the session with del request.session['data'], but that didn't work.

My session backend is a database, but Firefox makes a session cookie.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
nim4n
  • 1,813
  • 3
  • 21
  • 36

1 Answers1

1

Try

request.session.modified = True
chipmunk
  • 944
  • 8
  • 19
  • Try removing all the cookies and try again. – chipmunk Nov 29 '12 at 15:06
  • when i remove the firefox coockie after next search It made another coockie. I don't understand my session backend is db why firefox use coockie for session?! – nim4n Nov 29 '12 at 15:21
  • 1
    if you are using "django.contrib.sessions.backends.cached_db" than read the following https://docs.djangoproject.com/en/dev/topics/http/sessions/?from=olddocs#using-cached-sessions – chipmunk Nov 29 '12 at 18:47
  • I read this document . My backend is database.. my problem is why It works fine in chrome and have proble with firefox? – nim4n Nov 29 '12 at 18:54
  • Use this http://pypi.python.org/pypi/django-debug-toolbar and check the session data in firefox – chipmunk Nov 29 '12 at 19:05