django set session variable till end of day

Atma

I need to set a session variable that expires at the end of each day.

I know I can set a session variable like this:

request.session['my_variable'] = 'foo'

How can I then have this expire at the end of the day?

Andrew Johnson

You can set an entire session to expire at the end of the day with

request.session.set_expiry(seconds_until_end_of_day)

or you can set a default expiration for all session cookies in your app with the setting

SESSION_COOKIE_AGE

again in seconds. If you absolutely need to set a specific cookie to have a special expiration then you may have to look into the session backend.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is it possible to set a cookie to expiry at the end of session and after 1 day?

From Dev

How to create a middleware that set a session variable on login in Django?

From Dev

Set session variable in laravel

From Dev

Django session variable in JavaScript

From Dev

Editing session variable in Django

From Dev

grep till end of quote

From Dev

Showing message per day daily till the end of message using HTML and Javascript

From Dev

Set an array session variable in Yii

From Dev

How to set session variable in jsp

From Dev

PHP Unable to set a session variable

From Dev

Django: set session via Ajax

From Dev

Set session value in Template Django

From Dev

set cookie to expire at the end of current day

From Dev

Setting a session variable in django tests

From Dev

How to delete a session variable in django?

From Dev

Are variable identifiers totally needless, at the end of the day?

From Dev

Selenium: Scroll till end of the page

From Dev

Match till comma OR end of line

From Dev

Delete till end of sentence in vim

From Dev

File not being read till the end

From Dev

File not being read till the end

From Dev

Regex match till end of text

From Dev

Countdown till the end of the year - JS

From Dev

Set dynamic variable day in SSIS Package

From Dev

Set Magento 2 session variable over AJAX

From Dev

tmux set session variable for different sessions

From Dev

jQuery AJAX - Set PHP Session variable

From Dev

How to set a variable for the current OS session only

From Dev

How to set session variable in jquery/css?