For setting session variable:
request.session['idempresa'] = profile.idempresa
For getting session Data:
if 'idempresa' in request.session:
idempresa = request.session['idempresa']
For setting session variable:
request.session['idempresa'] = profile.idempresa
For getting session Data:
if 'idempresa' in request.session:
idempresa = request.session['idempresa']