Hello @kartik,
You can do this via Ajax. You'll need a simple Django view that updates the session variable, which the jQuery will call:
def update_session(request):
if not request.is_ajax() or not request.method=='POST':
return HttpResponseNotAllowed(['POST'])
request.session['mykey'] = 'myvalue'
return HttpResponse('ok')
and the JS:
$.post('/update_session/', function(data) {
alert(data);
});
Hope it helps!!
To know more about Java, join our Java course online today.
Thank You!!