Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django session doesn't work in Firefox

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.

like image 530
nim4n Avatar asked Nov 13 '22 16:11

nim4n


1 Answers

Try

request.session.modified = True
like image 184
chipmunk Avatar answered Nov 15 '22 05:11

chipmunk