From c920387faba8da2f65fca49d191b6a93a9becdba Mon Sep 17 00:00:00 2001
From: Adam Johnson <me@adamj.eu>
Date: Mon, 29 Nov 2021 16:57:34 +0000
Subject: [PATCH] Optimized SessionBase.get_expire_at_browser_close().

---
 django/contrib/sessions/backends/base.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/django/contrib/sessions/backends/base.py b/django/contrib/sessions/backends/base.py
index 5374965da8..f86f329550 100644
--- a/django/contrib/sessions/backends/base.py
+++ b/django/contrib/sessions/backends/base.py
@@ -275,9 +275,9 @@ class SessionBase:
         ``get_expiry_date()`` or ``get_expiry_age()`` to find the actual expiry
         date/age, if there is one.
         """
-        if self.get('_session_expiry') is None:
+        if (expiry := self.get('_session_expiry')) is None:
             return settings.SESSION_EXPIRE_AT_BROWSER_CLOSE
-        return self.get('_session_expiry') == 0
+        return expiry == 0
 
     def flush(self):
         """