Sessionid is not set to 'application/Cookies' in developer tools
I'm trying to implement a login function with Django and React. Reference: https://www.youtube.com/watch?v=diB38AvVkHw&ab_channel=Djangoroad When a post method is sent to login, the sessionid is set only in 'network/cookies'. Checking the 'application/cookies', only csrfToken is set.
I'm not sure why the sessionid wasn't set to the Cookies. Is there anything to cause this problem?
here is UserLogin view in django views.py
class UserLogin(APIView):
permission_classes = (permissions.AllowAny, )
authentication_classes = (SessionAuthentication, )
def post(self, request):
data = request.data
assert validate_email(data)
assert validate_password(data)
serializer = UserLoginSerializer(data=data)
if serializer.is_valid(raise_exception=True):
user = serializer.check_user(data)
login(request, user)
return Response({'user_id': user.user_id}, status=status.HTTP_200_OK)
Here is the react function to submit login form.
function submitLogin(e) {
e.preventDefault();
client
.post("/api/login", {
email: email,
password: password,
})
.then(function (res) {
setCurrentUser(true);
setUserId(res.data.user_id);
});
}