Search code examples
pythonpyramid

Python Pyramid - How to store data, convert to string in session and retrieve it on the next page?


I was required to store the data in session and retrieve it later on. My task is to select gifts and show the selected gift for confirmation on next page.

I followed the website here, but I don't understand what does this mean:

session['fred'] = 'yes'

Thank you, I'm a beginner in Python programming.


Solution

  • Sessions must be a dictionary where you store values as (key,value) pairs. So, in this case:

    session['fred'] = 'yes'
    

    'Fred' is the key and 'Yes' is the value.

    Learn more about python dictionaries, here: https://www.tutorialspoint.com/python/python_dictionary.htm

     session["abc"] = 123
     print (session["abc"]) this will get you 123