Cookies, Sessions and ORM
SUMMARY MAIN NOTES
HTTP is a Contents
stateless HTTP
application-layer HttpRequest Object
protocol. It is Cookies
extensible Session
Cookies
Django uses an Proxies
HttpRequest Object Middleware
containing the Object-Relational Map
details Type Mapping
Field Options
body
method
HTTP
GET/POST
parameters
An application- layer protocol for
Cookies requests and responses sent between
META i.e. client-server.
HTTP headers
Aspects of HTTP:
sessions
simple and human-readable
Cookies are a
small piece of data extensible, easy to introduce new functionality
server sends to a
stateless: no link between two requests being
client. They allow
successively carried out on the same
for web
connection. Could bring problems when trying
applications to
to interact with certain pages coherently, but
store limited
cookies solve that.
amounts of data
and remember
state information
HttpRequest Object
Cookies, Sessions and ORM 1
, e.g. used to Upon an HTTP Request, Django creates HttpRequest
check if a Object containing request details
request is from
Body: raw HTTP request body as a byte string
the same client
method
they can be
used to GET/POST parameters, a dictionary
manage Cookies: dictionary with all cookies
sessions such
META: all variable HTTP headers
as carts,
scores, sign-in session: dictionary with session values (set by
status middleware)
personalisation
such as Cookies
language and
UI A small piece of data a server sends to
track and
a user’s web browser. They allow web
record user applications to store limited amounts of
behaviour data and remember state information
Similarly, a session
uses cookies, but Used to determine if different requests come from
the same client, then generate a personalised or
it used to store
generic response as appropriate. Uses:
information on the
server about a Session management: user sign-in status,
user to be used shopping cart contents, game scores, or any
across multiple other user session-related details the server
pages of the needs to remember
website
Personalisation: user preferences such as
They are display language and UI theme
encrypted
Tracking: recording and analysing user
while users are
behaviour
not
automatically
created and
removed with
💡 Can send cookies through HTTP request
Set-Cookie: <cookie-name>=<cookie-value> . They
opening and can have an expiration date or max age.
Cookies, Sessions and ORM 2