{"id":75765,"date":"2020-01-20T12:03:05","date_gmt":"2020-01-20T06:33:05","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?p=75765"},"modified":"2024-04-12T14:17:16","modified_gmt":"2024-04-12T08:47:16","slug":"djangos-session-framework","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/","title":{"rendered":"Django\u2019s Session Framework"},"content":{"rendered":"<p>Imagine you had to log back in to a website every time you navigated to another page, or your favorite websites forgot all of your settings and you had to enter them again each time you visited?<\/p>\n<p>Modern websites could not provide the usability and convenience we are used to without some way of remembering who you are and your previous activities on the website. HTTP is, by design, stateless \u2013 there is no persistence between one request and the next, and there is no way the server can tell whether successive requests come from the same person.<\/p>\n<p>This lack of state is managed using sessions, which are a semi-permanent, two-way communication between your browser and the web server. When you visit a modern website, in the majority of cases, the web server will use an anonymous session to keep track of data relevant to your visit. The session is called anonymous because the web server can only record what you did, not who you are.<\/p>\n<p>We have all experienced this when we have returned to an eCommerce site at a later date and found the items we put in the cart are still there, despite not having provided any personal details.<br>\nSessions are most often persisted using the often maligned, but rarely understood cookie. Like all other web frameworks, Django also uses cookies, but does so in a more clever and secure manner, as you will see.<\/p>\n<p>Django provides full support for anonymous sessions. The session framework lets you store and retrieve arbitrary data on a per-site-visitor basis. It stores data on the server side and abstracts the sending and receiving of cookies. Cookies contain a session ID \u2013 not the data itself (unless you\u2019re using the cookie based backend); a more secure way of implementing cookies than some other frameworks.<\/p>\n<h3>Enabling Sessions<\/h3>\n<p>Sessions are implemented via a piece of middleware. The default settings.py created by django-admin startproject has SessionMiddleware activated. To enable session functionality, edit the MIDDLEWARE_CLASSES setting and make sure it contains &#8216;django.contrib.sessions.middleware.SessionMiddleware&#8217;.<\/p>\n<p>If you don\u2019t want to use sessions, you might as well remove the SessionMiddleware line from MIDDLEWARE_CLASSES and &#8216;django.contrib.sessions&#8217; from your INSTALLED_APPS. It\u2019ll save you a small bit of overhead.<\/p>\n<h3>Configuring The Session Engine<\/h3>\n<p>By default, Django stores sessions in your database (using the model django.contrib.sessions.models.Session). Though this is convenient, in some setups it\u2019s faster to store session data elsewhere, so Django can be configured to store session data on your file system or in your cache.<\/p>\n<h3>Using Database-Backed Sessions<\/h3>\n<p>If you want to use a database-backed session, you need to add &#8216;django.contrib.sessions&#8217; to your INSTALLED_APPS setting. Once you have configured your installation, run manage.py migrate to install the single database table that stores session data.<\/p>\n<h3>Using Cached Sessions<\/h3>\n<p>For better performance, you may want to use a cache-based session backend. To store session data using Django\u2019s cache system, you\u2019ll first need to make sure you\u2019ve configured your cache.<\/p>\n<p>You should only use cache-based sessions if you\u2019re using the Memcached cache backend. The local-memory cache backend doesn\u2019t retain data long enough to be a good choice, and it\u2019ll be faster to use file or database sessions directly instead of sending everything through the file or database cache backends. Additionally, the local-memory cache backend is NOT multi-process safe, therefore probably not a good choice for production environments.<\/p>\n<p>If you have multiple caches defined in CACHES, Django will use the default cache. To use another cache, set SESSION_CACHE_ALIAS to the name of that cache. Once your cache is configured, you\u2019ve got two choices for how to store data in the cache:<\/p>\n<ul>\n<li>Set SESSION_ENGINE to &#8220;django.contrib.sessions.backends.cache&#8221; for a simple caching session store. Session data will be stored directly in your cache. However, session data may not be persistent: cached data can be evicted if the cache fills up or if the cache server is restarted.<\/li>\n<li>For persistent, cached data, set SESSION_ENGINE to &#8220;django.contrib.sessions.backends.cached_db&#8221;. This uses a write-through cache \u2013 every write to the cache will also be written to the database. Session reads only use the database if the data is not already in the cache.<\/li>\n<\/ul>\n<p>Both session stores are quite fast, but the simple cache is faster because it disregards persistence. In most cases, the cached_db backend will be fast enough, but if you need that last bit of performance, and are willing to let session data be expunged from time to time, the cache backend is for you. If you use the cached_db session backend, you also need to follow the configuration instructions for the using database-backed sessions.<\/p>\n<h3>Using File-Based Sessions<\/h3>\n<p>To use file-based sessions, set the SESSION_ENGINE setting to &#8220;django.contrib.sessions.backends.file&#8221;. You might also want to set the SESSION_FILE_PATH setting (which defaults to output from tempfile.gettempdir(), most likely \/tmp) to control where Django stores session files. Be sure to check that your Web server has permissions to read and write to this location.<\/p>\n<h3>Using Cookie-Based Sessions<\/h3>\n<p>To use cookies-based sessions, set the SESSION_ENGINE setting to &#8220;django.contrib.sessions.backends.signed_cookies&#8221;. The session data will be stored using Django\u2019s tools for cryptographic signing and the SECRET_KEY setting.<\/p>\n<p>It\u2019s recommended to leave the SESSION_COOKIE_HTTPONLY setting on True to prevent access to the stored data from JavaScript.<\/p>\n<h3>Warnings<\/h3>\n<p><strong>If the SECRET_KEY is not kept secret and you are using the PickleSerializer, this can lead to arbitrary remote code execution.<\/strong> &#8211; An attacker in possession of the SECRET_KEY can not only generate falsified session data, which your site will trust, but also remotely execute arbitrary code, as the data is serialized using pickle. If you use cookie-based sessions, pay extra care that your secret key is always kept completely secret, for any system which might be remotely accessible.<\/p>\n<p><strong>The session data is signed but not encrypted<\/strong> &#8211; When using the cookies backend, the session data can be read by the client. A MAC (Message Authentication Code) is used to protect the data against changes by the client, so that the session data will be invalidated when being tampered with. The same invalidation happens if the client storing the cookie (e.g. your user\u2019s browser) can\u2019t store all of the session cookie and drops data. Even though Django compresses the data, it\u2019s still entirely possible to exceed the common limit of 4096 bytes per cookie.<\/p>\n<p><strong>No freshness guarantee<\/strong> &#8211; Note also that while the MAC can guarantee the authenticity of the data (that it was generated by your site, and not someone else), and the integrity of the data (that it is all there and correct), it cannot guarantee freshness i.e. that you are being sent back the last thing you sent to the client. This means that for some uses of session data, the cookie backend might open you up to replay attacks. Unlike other session backends which keep a server-side record of each session and invalidate it when a user logs out, cookie-based sessions are not invalidated when a user logs out. Thus if an attacker steals a user\u2019s cookie, they can use that cookie to login as that user even if the user logs out. Cookies will only be detected as \u2018stale\u2019 if they are older than your SESSION_COOKIE_AGE.<\/p>\n<p>Finally, assuming the above warnings have not discouraged you from using cookie based sessions: the size of a cookie can also have an impact on the speed of your site.<\/p>\n<h3>Using Sessions in Views<\/h3>\n<p>When SessionMiddleware is activated, each HttpRequest object \u2013 the first argument to any Django view function \u2013 will have a session attribute, which is a dictionary-like object. You can read it and write to request.session at any point in your view. You can also edit it multiple times.<\/p>\n<p>All session objects inherit from the base class backends.base.SessionBase. It has the following standard dictionary methods:<\/p>\n<ul>\n<li>__getitem__(key)<\/li>\n<li>__setitem__(key, value)<\/li>\n<li>__delitem__(key)<\/li>\n<li>__contains__(key)<\/li>\n<li>get(key, default=None)<\/li>\n<li>pop(key)<\/li>\n<li>keys()<\/li>\n<li>items()<\/li>\n<li>setdefault()<\/li>\n<li>clear()<\/li>\n<\/ul>\n<p>It also has these methods:<\/p>\n<p>flush() &#8211; Delete the current session data from the session and delete the session cookie. This is used if you want to ensure that the previous session data can\u2019t be accessed again from the user\u2019s browser (for example, the django.contrib.auth.logout() function calls it).<\/p>\n<p>set_test_cookie() &#8211; Sets a test cookie to determine whether the user\u2019s browser supports cookies. Due to the way cookies work, you won\u2019t be able to test this until the user\u2019s next page request.<\/p>\n<p>test_cookie_worked() &#8211; Returns either True or False, depending on whether the user\u2019s browser accepted the test cookie. Due to the way cookies work, you\u2019ll have to call set_test_cookie() on a previous, separate page request.<br>\ndelete_test_cookie() &#8211; Deletes the test cookie. Use this to clean up after yourself.<\/p>\n<p>set_expiry(value) &#8211; Sets the expiration time for the session. You can pass a number of different values:<\/p>\n<ul>\n<li>If value is an integer, the session will expire after that many seconds of inactivity.<\/li>\n<li>For example, calling request.session.set_expiry(300) would make the session expire in 5 minutes.<\/li>\n<li>If value is a datetime or timedelta object, the session will expire at that specific date\/time. Note that datetime and timedelta values are only serializable if you are using the PickleSerializer.<\/li>\n<li>If value is 0, the user\u2019s session cookie will expire when the user\u2019s Web browser is closed.<\/li>\n<li>If value is None, the session reverts to using the global session expiry policy.<\/li>\n<li>Reading a session is not considered activity for expiration purposes. Session expiration is computed from the last time the session was modified.<\/li>\n<\/ul>\n<p><strong>get_expiry_age()<\/strong> &#8211; Returns the number of seconds until this session expires. For sessions with no custom expiration (or those set to expire at browser close), this will equal SESSION_COOKIE_AGE. This function accepts two optional keyword arguments:<\/p>\n<ul>\n<li><strong>modification<\/strong>: last modification of the session, as a datetime object. Defaults to the current time.<\/li>\n<li><strong>expiry<\/strong>: expiry information for the session, as a datetime object, an int (in seconds), or None. Defaults to the value stored in the session by set_expiry(), if there is one, or None.<\/li>\n<\/ul>\n<p><strong>get_expiry_date()<\/strong> &#8211; Returns the date this session will expire. For sessions with no custom expiration (or those set to expire at browser close), this will equal the date SESSION_COOKIE_AGE seconds from now. This function accepts the same keyword arguments as get_expiry_age().<\/p>\n<p><strong>get_expire_at_browser_close()<\/strong> &#8211; Returns either True or False, depending on whether the user\u2019s session cookie will expire when the user\u2019s Web browser is closed.<\/p>\n<p><strong>clear_expired()<\/strong> &#8211; Removes expired sessions from the session store. This class method is called by clearsessions.<\/p>\n<p><strong>cycle_key()<\/strong> &#8211; Creates a new session key while retaining the current session data. django.contrib.auth.login() calls this method to mitigate against session fixation.<\/p>\n<h3>Session Object Guidelines<\/h3>\n<ul>\n<li>&nbsp;Use normal Python strings as dictionary keys on request.session. This is more of a convention than a hard-and-fast rule.<\/li>\n<li>Session dictionary keys that begin with an underscore are reserved for internal use by Django.<\/li>\n<li>Don\u2019t override request.session with a new object, and don\u2019t access or set its attributes. Use it like a Python dictionary.<\/li>\n<\/ul>\n<p><strong>Session Serialization<\/strong> &#8211; Before version 1.6, Django defaulted to using pickle to serialize session data before storing it in the backend. If you\u2019re using the signed cookie session backend and SECRET_KEY is known by an attacker (there isn\u2019t an inherent vulnerability in Django that would cause it to leak), the attacker could insert a string into their session which, when unpickled, executes arbitrary code on the server. The technique for doing so is simple and easily available on the internet.<\/p>\n<p>Although the cookie session storage signs the cookie-stored data to prevent tampering, a SECRET_KEY leak immediately escalates to a remote code execution vulnerability. This attack can be mitigated by serializing session data using JSON rather than pickle. To facilitate this, Django 1.5.3 introduced a new setting, SESSION_SERIALIZER, to customize the session serialization format. For backwards compatibility, this setting defaults to using django.contrib.sessions.serializers.PickleSerializer in Django 1.5.x, but, for security hardening, defaults to django.contrib.sessions.serializers.JSONSerializer from Django 1.6 onward.<\/p>\n<p>Even with the caveats described in custom-serializers, we highly recommend sticking with JSON serialization especially if you are using the cookie backend.<\/p>\n<h3>Bundled Serializers<\/h3>\n<p>serializers.JSONSerializer &#8211; A wrapper around the JSON serializer from django.core.signing. Can only serialize basic data types. In addition, as JSON supports only string keys, note that using non-string keys in request.session won\u2019t work as expected:<\/p>\n<p>&gt;&gt;&gt; # initial assignment<br>\n&gt;&gt;&gt; request.session[0] = &#8216;bar&#8217;<br>\n&gt;&gt;&gt; # subsequent requests following serialization &amp;<br>\ndeserialization<br>\n&gt;&gt;&gt; # of session data<br>\n&gt;&gt;&gt; request.session[0] # KeyError<br>\n&gt;&gt;&gt; request.session[&#8216;0&#8217;]\n&#8216;bar&#8217;<\/p>\n<p><strong>serializers.PickleSerializer<\/strong> &#8211; Supports arbitrary Python objects, but, as described above, can lead to a remote code execution vulnerability if SECRET_KEY becomes known by an attacker.<\/p>\n<p><strong>Write Your Own Serializer<\/strong> &#8211; Note that unlike PickleSerializer, the JSONSerializer cannot handle arbitrary Python data types. As is often the case, there is a trade-off between convenience and security. If you wish to store more advanced data types including datetime and Decimal in JSON backed sessions, you will need to write a custom serializer (or convert such values to a JSON serializable object before storing them in request.session).<\/p>\n<p>While serializing these values is fairly straightforward (django.core.serializers.json.DateTimeAwareJSONEncoder may be helpful), writing a decoder that can reliably get back the same thing that you put in is more fragile. For example, you run the risk of returning a datetime that was actually a string that just happened to be in the same format chosen for datetime).<\/p>\n<p>Your serializer class must implement two methods, dumps(self, obj) and loads(self, data), to serialize and deserialize the dictionary of session data, respectively.<br>\nSetting Test Cookies<br>\nAs a convenience, Django provides an easy way to test whether the user\u2019s browser accepts cookies. Just call the set_test_cookie() method of request.session in a view, and call test_cookie_worked() in a subsequent view \u2013 not in the same view call.<\/p>\n<p>This awkward split between set_test_cookie() and test_cookie_worked() is necessary due to the way cookies work. When you set a cookie, you can\u2019t actually tell whether a browser accepted it until the browser\u2019s next request. It\u2019s good practice to use delete_test_cookie() to clean up after yourself. Do this after you\u2019ve verified that the test cookie worked.<\/p>\n<p>Here\u2019s a typical usage example:<\/p>\n<p>def login(request):<br>\nif request.method == &#8216;POST&#8217;:<br>\nif request.session.test_cookie_worked():<br>\nrequest.session.delete_test_cookie()<br>\nreturn HttpResponse(&#8220;You&#8217;re logged in.&#8221;)<br>\nelse:<br>\nreturn HttpResponse(&#8220;Please enable cookies and try again.&#8221;)<br>\nrequest.session.set_test_cookie()<br>\nreturn render_to_response(&#8216;foo\/login_form.html&#8217;)<br>\nUsing Sessions out of Views<br>\nThe examples in this section import the SessionStore object directly from the django.contrib.sessions.backends.db backend. In your own code, you should consider importing SessionStore from the session engine designated by SESSION_ENGINE, as below:<\/p>\n<p>&gt;&gt;&gt; from importlib import import_module<br>\n&gt;&gt;&gt; from django.conf import settings<br>\n&gt;&gt;&gt; SessionStore = import_module(settings.SESSION_ENGINE).SessionStore<\/p>\n<p>An API is available to manipulate session data outside of a view:<\/p>\n<p>&gt;&gt;&gt; from django.contrib.sessions.backends.db import SessionStore<br>\n&gt;&gt;&gt; s = SessionStore()<br>\n&gt;&gt;&gt; # stored as seconds since epoch since datetimes are not serializable in JSON.<br>\n&gt;&gt;&gt; s[&#8216;last_login&#8217;] = 1376587691<br>\n&gt;&gt;&gt; s.save()<br>\n&gt;&gt;&gt; s.session_key<br>\n&#8216;2b1189a188b44ad18c35e113ac6ceead&#8217;<\/p>\n<p>&gt;&gt;&gt; s = SessionStore(session_key=&#8217;2b1189a188b44ad18c35e113ac6ceead&#8217;)<br>\n&gt;&gt;&gt; s[&#8216;last_login&#8217;]\n1376587691<\/p>\n<p>In order to mitigate session fixation attacks, sessions keys that don\u2019t exist are regenerated:<br>\n&gt;&gt;&gt; from django.contrib.sessions.backends.db import SessionStore<br>\n&gt;&gt;&gt; s = SessionStore(session_key=&#8217;no-such-session-here&#8217;)<br>\n&gt;&gt;&gt; s.save()<br>\n&gt;&gt;&gt; s.session_key<br>\n&#8216;ff882814010ccbc3c870523934fee5a2&#8217;<\/p>\n<p>If you\u2019re using the django.contrib.sessions.backends.db backend, each session is just a normal Django model. The Session model is defined in django\/contrib\/sessions\/models.py. Because it\u2019s a normal model, you can access sessions using the normal Django database API:<\/p>\n<p>&gt;&gt;&gt; from django.contrib.sessions.models import Session<br>\n&gt;&gt;&gt; s = Session.objects.get(pk=&#8217;2b1189a188b44ad18c35e113ac6ceead&#8217;)<br>\n&gt;&gt;&gt; s.expire_date<br>\ndatetime.datetime(2005, 8, 20, 13, 35, 12)<\/p>\n<p>Note that you\u2019ll need to call get_decoded() to get the session dictionary. This is necessary because the dictionary is stored in an encoded format:<\/p>\n<p>&gt;&gt;&gt; s.session_data<br>\n&#8216;KGRwMQpTJ19hdXRoX3VzZXJfaWQnCnAyCkkxCnMuMTExY2ZjODI2Yj&#8230;&#8217;<br>\n&gt;&gt;&gt; s.get_decoded()<br>\n{&#8216;user_id&#8217;: 42}<\/p>\n<p>When Sessions Are Saved &#8211; By default, Django only saves to the session database when the session has been modified \u2013 that is if any of its dictionary values have been assigned or deleted:<\/p>\n<p># Session is modified.<br>\nrequest.session[&#8216;foo&#8217;] = &#8216;bar&#8217;<\/p>\n<p># Session is modified.<br>\ndel request.session[&#8216;foo&#8217;]\n<p># Session is modified.<br>\nrequest.session[&#8216;foo&#8217;] = {}<\/p>\n<p># Gotcha: Session is NOT modified, because this alters<br>\n# request.session[&#8216;foo&#8217;] instead of request.session.<br>\nrequest.session[&#8216;foo&#8217;][&#8216;bar&#8217;] = &#8216;baz&#8217;<\/p>\n<p>In the last case of the above example, we can tell the session object explicitly that it has been modified by setting the modified attribute on the session object:<\/p>\n<p>request.session.modified = True<\/p>\n<p>To change this default behavior, set the SESSION_SAVE_EVERY_REQUEST setting to True. When set to True, Django will save the session to the database on every single request. Note that the session cookie is only sent when a session has been created or modified. If SESSION_SAVE_EVERY_REQUEST is True, the session cookie will be sent on every request. Similarly, the expires part of a session cookie is updated each time the session cookie is sent. The session is not saved if the response\u2019s status code is 500.<\/p>\n<p><strong>Browser-Length Sessions Vs. Persistent Sessions<\/strong> &#8211; You can control whether the session framework uses browser-length sessions vs. persistent sessions with the SESSION_EXPIRE_AT_BROWSER_CLOSE setting. By default, SESSION_EXPIRE_AT_BROWSER_CLOSE is set to False, which means session cookies will be stored in users\u2019 browsers for as long as SESSION_COOKIE_AGE. Use this if you don\u2019t want people to have to log in every time they open a browser.<\/p>\n<p><strong>If SESSION_EXPIRE_AT_BROWSER_CLOSE is set to True, Django will use browser-length cookies<\/strong> \u2013 cookies that expire as soon as the user closes their browser.<\/p>\n<p>Some browsers (Chrome, for example) provide settings that allow users to continue browsing sessions after closing and re-opening the browser. In some cases, this can interfere with the SESSION_EXPIRE_AT_BROWSER_CLOSE setting and prevent sessions from expiring on browser close. Please be aware of this while testing Django applications which have the SESSION_EXPIRE_AT_BROWSER_CLOSE setting enabled.<\/p>\n<p><strong>Clearing The Session Store<\/strong> &#8211; As users create new sessions on your website, session data can accumulate in your session store. Django does not provide automatic purging of expired sessions. Therefore, it\u2019s your job to purge expired sessions on a regular basis. Django provides a clean-up management command for this purpose: clearsessions. It\u2019s recommended to call this command on a regular basis, for example as a daily cron job.<\/p>\n<p>Note that the cache backend isn\u2019t vulnerable to this problem, because caches automatically delete stale data. Neither is the cookie backend, because the session data is stored by the users\u2019 browsers.<\/p>\n\n\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/certified-django-developer\/\" target=\"_blank\" rel=\"noreferrer noopener\">Back to Tutorial<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Imagine you had to log back in to a website every time you navigated to another page, or your favorite websites forgot all of your settings and you had to enter them again each time you visited? Modern websites could not provide the usability and convenience we are used to without some way of remembering&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[8655],"tags":[8802],"class_list":["post-75765","page","type-page","status-publish","hentry","category-django-web-development","tag-djangos-session-framework"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Django\u2019s Session Framework - Tutorial<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Django\u2019s Session Framework - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Imagine you had to log back in to a website every time you navigated to another page, or your favorite websites forgot all of your settings and you had to enter them again each time you visited? Modern websites could not provide the usability and convenience we are used to without some way of remembering...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:47:16+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"17 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/\",\"name\":\"Django\u2019s Session Framework - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2020-01-20T06:33:05+00:00\",\"dateModified\":\"2024-04-12T08:47:16+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Django\u2019s Session Framework\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Django\u2019s Session Framework - Tutorial","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/","og_locale":"en_US","og_type":"article","og_title":"Django\u2019s Session Framework - Tutorial","og_description":"Imagine you had to log back in to a website every time you navigated to another page, or your favorite websites forgot all of your settings and you had to enter them again each time you visited? Modern websites could not provide the usability and convenience we are used to without some way of remembering...","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:47:16+00:00","twitter_misc":{"Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/","name":"Django\u2019s Session Framework - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2020-01-20T06:33:05+00:00","dateModified":"2024-04-12T08:47:16+00:00","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/djangos-session-framework\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Django\u2019s Session Framework"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/75765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=75765"}],"version-history":[{"count":4,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/75765\/revisions"}],"predecessor-version":[{"id":83380,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/75765\/revisions\/83380"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=75765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=75765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=75765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}