Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3930754
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:17:13+00:00 2026-05-19T23:17:13+00:00

In one of my views I’m saving a few sessions like this: def myview(request):

  • 0

In one of my views I’m saving a few sessions like this:

def myview(request):
    request.session['session_1'] = 'value1
    request.session['session_2'] = 'value2'

Then on the same view function and also other views found on other applications I’m trying to get the session values like this:

   session_value1 = request.session['session_1'] 
   session_value2 = request.session['session_2']

I would like the values for the ‘session_1’ and ‘session_2’ to never expire and also be available anywhere on the web site (like other views on the same application and views on other applications).

My problem is that when I’m on the same page/view (just described above) when I do a refresh to the page I have to problems retrieving session_1 and session_2 values. But let’s say if I go to a different page and then come back to the original page the ‘session_1’ and ‘session_2’ values are gone. Also the values of the ‘session_1’ and ‘session_2’ are not available on any other page/view.

I have no settings for sessions on my settings.py so all the values for sessions are the default ones.

Any thoughts why the sessions are not saved? Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:17:13+00:00Added an answer on May 19, 2026 at 11:17 pm

    My problem is that when I’m on the
    same page/view (just described above)
    when I do a refresh to the page I have
    to problems retrieving session_1 and
    session_2 values.

    So you are setting and retrieving on the same view? Can I see that view? Are you literally assigning ‘value1’ or is there otherwise any chance your view is causing problems?

    Is the session_key the same between page views?

    Copy and paste this into your root urls.py and visit /session-test/

    from django import http
    
    def session_test_1(request):
        request.session['test'] = 'Session Vars Worked!'
        return http.HttpResponseRedirect('done/?session=%s' % request.session.session_key)
    
    def session_test_2(request):
        return http.HttpResponse('<br>'.join([
            request.session.session_key,
            request.GET.get('session'),
            request.session.get('test', 'Session is Borked :(')
             ]))
    
    
    urlpatterns += patterns('',
            (r'^session-test/$', session_test_1),
            (r'^session-test/done/$', session_test_2),
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this in one of my views <li <?php $isCurrent ?
I have code in one of my views that looks like this below where
Considering this LinearLayout containing.. One nested Linear Layout with two child views one imageView
This has gotten me extremely confused. I have one scroll views on a page
How to load multiple views one after the another once this view is displayed
I want to add two views one after the other, I used this way
I have 2 customer views one for create and one for edit. I am
I have two views in my ViewFlipper . One of views contains a ListView
One of our views has a ScrollView as its root layout. When the device
I have two views within one .xib (one view for landscape, another for portrait).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.