Django session doesn t work in Firefox

0 votes
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']
    ...
It works fine in Chrome. 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. How can I solve this issue?
May 6, 2019 in Python by ana1504.k
• 7,910 points
1,568 views

1 answer to this question.

0 votes
You can try this:

request.session.modified = True

I hope this helps!
answered May 6, 2019 by SDeb
• 13,300 points

Related Questions In Python

0 votes
1 answer

How to update Django session variable in javascript?

Hello @kartik, You can do this via Ajax. ...READ MORE

answered Jul 30, 2020 in Python by Niroj
• 82,840 points
6,985 views
0 votes
1 answer

How to expire session due to inactivity in Django?

Hello @kartik, Expire the session on browser close ...READ MORE

answered Aug 13, 2020 in Python by Niroj
• 82,840 points
10,314 views
+1 vote
1 answer

Why does x,y = zip(*zip(a,b)) work in Python?

I'm extremely new to Python so this ...READ MORE

answered Aug 23, 2018 in Python by Priyaj
• 58,020 points
1,672 views
0 votes
1 answer

How does insertion work in Python?

Or, this one: def ins_sort(k): ...READ MORE

answered Oct 8, 2018 in Python by charlie_brown
• 7,720 points
824 views
0 votes
1 answer

how to download and install Django rest framework?

To install Django, you can simply open ...READ MORE

answered Apr 24, 2018 in Python by Christine
• 15,790 points
1,970 views
0 votes
1 answer
0 votes
1 answer

Host not allowed

Go to your project directory cd project cd project ALLOWED_HOSTS ...READ MORE

answered Aug 9, 2018 in AWS by Priyaj
• 58,020 points
1,743 views
0 votes
1 answer

How does % work in Python?

The % (modulo) operator yields the remainder ...READ MORE

answered Oct 10, 2018 in Python by SDeb
• 13,300 points
834 views
0 votes
1 answer

How do sets work in Python?

Define the __hash__ method to return a ...READ MORE

answered Apr 12, 2019 in Python by SDeb
• 13,300 points
875 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP