title: Can't set user session with Vue and Django
body: <p>I have the Vue app and the Django rest framework api separately.
  One on localhost:8080 (vue app) and the rest api on localhost:8000.</p>
  
  <p>So, I created an APIView that is supposed to log the user in when they make a post request:</p>
  
  <pre><code>class LoginUserAPIView(APIView):
      permission_classes = () # login should be accessed by anyone, no restrictions.
      def post(self, request, format=None):
          username = request.data['username']
          password = request.data['password']
  
          user = authenticate(username=username, password=password)
  
          if user is not None:
              login(request, user)
              user = UserSerializer(user)
              return Response({'success': 'Logged in', 'user': user.data})
          return Response({'wrong': 'username or password not correct, try again'}, status=status.HTTP_401_UNAUTHORIZED)
  </code></pre>
  
  <p>And I was trying to get the user session from django with axios:</p>
  
  <pre><code>login() {
        this.isLoading = true;
        return axios({
          method: 'post',
          url: 'http://localhost:8000/api/login_user',
          data: {
            username: this.name,
            password: this.password
          },
          headers: {
            'Content-Type': 'application/json'
          }
        })
        .then(response =&gt; {
          this.$store.commit('loginAuth', true); // setting isAuth to true in vuex store.
          this.$store.commit('setUser', response.data.user); // to access the user object since I don't use django templates
          this.$router.push({name: 'page'}); // redirect to random test page that requires authorization so I can see if everything went fine.
        })
        .catch(err =&gt; {
          console.error(err);
          if (err.response.status == 401) {
            alert(err.response.data.wrong);
            this.isLoading = false;
          }
        })
  </code></pre>
  
  <p>but I was naive and I thought this would work, so when I checked the vue app for any cookies or sessions, nothing.</p>
  
  <p>How could I set user session for a separate vue app?</p>
  
  <p>Thanks in advance, I apologize for my lack of knowledge.</p>