I asked a similar question before, but I did some more research, and this iteration should be a little different. It seems that several SO users had a problem with registering and logging users in the same view and were not answered.
The problem is that I register, authenticate and authorize the user in the same Django view. For most users who are good, but for other users, their subsequent request (they click on the link on my site) returns an Anonymous user. One way or another, the logged-in user loses his session and is redirected to a page on my sieve, does not require authentication.
When they are registered in clean login mode (as opposed to register + login), the session data remains in tact. It seems that the problem is registering and registering in one view.
See this post for the same issue: https://stackoverflow.com/questions/1693726/problem-with-combined-authentication-login-view .
It has been suggested that this is potentially a thread problem. I also saw that he suggested that he refers to a server for caching session data.
Any thoughts on what this really applies to? I cannot reproduce the error that really holds me back.
EDIT - I should note that I am using the default database supported database.
Here is my view in registration / login mode
def splash_register(request): if request.session.get('beta'): if request.method=='POST': userform=MyUserCreationForm(request.POST) if userform.is_valid(): #username of <30 char is required by Django User model. I'm storing username as a hash of user email user=userform.save(commit=False) user.username=hash(user.email) user.save() username=user.username password=str(userform.cleaned_data['password']) user=auth.authenticate(username=username, password=password) if user is not None: auth.login(request,user) request.session['first_visit']=True return HttpResponseRedirect("/") else: return HttpResponseRedirect('/splash/register/') else: userform=MyUserCreationForm(request.POST) return render_to_response("website/splash_register.html", {'userform':userform}, context_instance=RequestContext(request)) return render_to_response("website/splash_register.html", context_instance=RequestContext(request)) else: return HttpResponseRedirect('/splash/')
django caching cookies apache session
Ben Apr 25 2018-11-11T00: 00Z
source share