$.cookie('keywords', input); if ($.cookie("keywords")){ $("input[name=filter]").val($.cookie("keywords")); } } WebDirectory/static/js/init.js WebDirectory/static/js/init.js storing data retrieving data
(aka token) between the browser and the web application • This session id should be unique and unforgeable (usually a long random number or a hash) • This session id is bind to key/value pairs data
'nb_visits' in request.session: n = int(request.session['nb_visits']) + 1 else: n = 1 request.session['nb_visits'] = n response = render_to_response('WebDirectory/index.html', {'entry_list': entry_list, 'nb_visits': n}) return response WebDirectory/views.py storing data retrieving data
session values are still on the server) Program use flush() in the view to delete the current session data and regenerate the session key Command python manage.py clearsessions deletes any session in the session table whose expire_date is in the past
a login and password and send it to the server (HTTP POST request) 2.Verify the login/password based on information stored on the server (usually in the database) 3.Start a session if the login password matches i.e. once the user has been successfully authenticated 4.Grant access to resources according to the session
import authenticate, login def login_view(request): username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) # Redirect to a success page. else: # Return a 'disabled account' error message else: # Return an 'invalid login' error message. example
... return render(request, 'WebDirectory/index.html',\ { ... 'admin': request.user.is_superuser}) WebDirectory/views.py This is absolutely not secure !!!