Get as below, no need to think about definitions (If it is empty, it will be divided into cases in the subsequent processing). p> ``` variable= request.session.get('Session storage information variable name') ``` ``` ex) cart = request.session.get('cart') ```
Overwrite the session after adding additional information to the variable as shown below. p> ``` variable.append(Additional Information) request.session['Session storage information variable name'] =variable ``` ``` ex) cart.append(product_id) request.session['cart'] = cart ```
Overwrite the session after creating a formal variable that does not have deletion information as shown below. p> ``` for mantissa(anything is fine)in variable: if mantissa!=Delete information: Formal variable.append(mantissa) request.session['Session storage information variable name'] =Formal variable ``` ``` ex) for p in cart: if p != product_id: filtered.append(p) request.session['cart'] = filtered ```
Recommended Posts