Index: AUTHORS
===================================================================
--- AUTHORS	(revision 5468)
+++ AUTHORS	(working copy)
@@ -229,7 +229,7 @@
     Karen Tracey <graybark@bellsouth.net>
     Makoto Tsuyuki <mtsuyuki@gmail.com>
     tt@gurgle.no
-    Amit Upadhyay
+    Amit Upadhyay <http://www.amitu.com/blog/>
     Geert Vanderkelen
     viestards.lists@gmail.com
     Milton Waddams
Index: django/contrib/sessions/middleware.py
===================================================================
--- django/contrib/sessions/middleware.py	(revision 5468)
+++ django/contrib/sessions/middleware.py	(working copy)
@@ -48,6 +48,13 @@
     def delete_test_cookie(self):
         del self[TEST_COOKIE_NAME]
 
+    def set_life(self, val):
+        """ 
+            sets the life of the session, irrespective of global settings. 
+            val is in seconds. 
+        """
+        self["_expires_on"] = TILL_BROWSER_CLOSE
+
     def _get_session(self):
         # Lazily loads session from storage.
         self.accessed = True
@@ -92,15 +99,20 @@
                     obj = Session.objects.get_new_session_object()
                     session_key = obj.session_key
 
-                if settings.SESSION_EXPIRE_AT_BROWSER_CLOSE:
-                    max_age = None
-                    expires = None
-                else:
-                    max_age = settings.SESSION_COOKIE_AGE
-                    expires = datetime.datetime.strftime(datetime.datetime.utcnow() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE), "%a, %d-%b-%Y %H:%M:%S GMT")
-                new_session = Session.objects.save(session_key, request.session._session,
-                    datetime.datetime.now() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE))
-                response.set_cookie(settings.SESSION_COOKIE_NAME, session_key,
+                now = datetime.datetime.now()
+                delta_yield = now + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE)
+                if settings.SESSION_EXPIRE_AT_BROWSER_CLOSE and not request.session.get("_expires_on"):
+                    max_age = None 
+                    expires = None 
+                else: 
+                    delta_yield = request.session.get("_expires_on", delta_yield)
+                    max_age_timedelta = delta_yield - now
+                    max_age = max_age_timedelta.days * 24 * 60 * 60 + max_age_timedelta.seconds
+                    expires = datetime.datetime.strftime(delta_yield, "%a, %d-%b-%Y %H:%M:%S GMT")
+                Session.objects.save(session_key, request.session._session, delta_yield)
+                response.set_cookie(
+                    settings.SESSION_COOKIE_NAME, session_key,
                     max_age=max_age, expires=expires, domain=settings.SESSION_COOKIE_DOMAIN,
-                    secure=settings.SESSION_COOKIE_SECURE or None)
+                    secure=settings.SESSION_COOKIE_SECURE or None
+                )
         return response
Index: docs/sessions.txt
===================================================================
--- docs/sessions.txt	(revision 5468)
+++ docs/sessions.txt	(working copy)
@@ -58,7 +58,7 @@
 
     * ``items()``
 
-It also has these three methods:
+It also has these four methods:
 
     * ``set_test_cookie()``
       Sets a test cookie to determine whether the user's browser supports
@@ -75,6 +75,12 @@
     * ``delete_test_cookie()``
       Deletes the test cookie. Use this to clean up after yourself.
 
+    * ``set_life(val)``
+      It takes an integer, number of seconds for which the session should be 
+      valid. Calling set_life will overwrite the global/default session expiry 
+      policy. See `browser-length sessions vs. persistent sessions` for 
+      default session expiry policy.
+
 You can edit ``request.session`` at any point in your view. You can edit it
 multiple times.
 
@@ -217,6 +223,9 @@
 her browser. Use this if you want people to have to log in every time they open
 a browser.
 
+These settings are global defaults, and can be overwritten by explicitly calling
+``request.session.set_life()`` as described above.
+
 Clearing the session table
 ==========================
 
