session在set和调用时其实分别做了三步:
def fileupload(request): request.session['k1'] = 'ppp' ''' 1、生成一个随机字符串 2、set_cookie('session_id','ddddddddddd') 3、django_session: ddddddddddd {'k1':ppp} ''' k1 = request.session['k1'] ''' 1、ddddddddddd = get_cookie('sessionid') 2、去数据库里查询出:{‘k1’:ppp} 3、k1 = 'ppp' '''