title: how to set cookie with httponly flag in vuejs and vuex that cookie cames from server(Laravel)
body: <p>I have one VueJs project as front-end and one Laravel project as back-end using for making api and server.</p>
  
  <p>I work with <a href="https://jwt-auth.readthedocs.io/en/develop/" rel="nofollow noreferrer">jwt</a> in laravel, it returns jwt token that contains user info. </p>
  
  <p><strong>Problem</strong>:</p>
  
  <p>I need to store this token in cookie with HTTPOnly flag but I don't know where and how set this cookie!? In server side (Laravel)?In Client side (VueJs)?</p>
  
  <p><strong>Codes:</strong></p>
  
  <p>My AuthController in Laravel:</p>
  
  <pre><code>  public function login()
      {
          $credentials = request(['email', 'password']);
  
          if (! $token = auth()-&gt;attempt($credentials)) {
              return response()-&gt;json(['error' =&gt; 'Unauthorized'], 401);
          }
  
          return $this-&gt;respondWithToken($token);
      }
  
  
    protected function respondWithToken($token)
      {
          return response()-&gt;json([
              'access_token' =&gt; $token,
              'token_type'   =&gt; 'bearer',
              'expires_in'   =&gt; auth()-&gt;factory()-&gt;getTTL() * 60
          ]);
      }
  </code></pre>
  
  <p>it returns:</p>
  
  <pre><code>{
      "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC92dWV4LmNhY3R1c3dlYi5pclwvYXBpXC9sb2dpbiIsImlhdCI6MTU3MzkxNDA1NSwiZXhwIjoxNTczODQ3NTQ2YWEiLCJ1c2VyIjp7ImlkIjozLCJuYW1lIjoiYWxpIiwiZW1haWwiOiJhQGEuY29tIiwicm9sZSI6IjIiLCJlbWFpbF92ZXJpZmllZF9hdCI6bnVsbCwiY3JlYXRlZF9hdCI6IjIwMTktMTEtMTQgMDg6MDU6NDUiLCJ1cGRhdGVkX2F0IjoiMjAxOS0xMS0xNCAwODowNTo0NSJ9fQ.Ow785CLmaAckZR9iowVkEMX6AxBQw7JSklt3Vp1btAcG4",
      "token_type": "bearer",
      "expires_in": 3600
  }
  </code></pre>
  
  <p>And in my Vuex store actions:</p>
  
  <pre><code>const actions = {
      login({commit}, user) {
          return new Promise((resolve, reject) =&gt; {
              commit('auth_request');
              Axios.post(`${api_base_url}/login`, user)
              .then(resp =&gt; {
                  const token = resp.data.access_token;
                  commit('auth_success', token, user);
                  resolve(resp)
              })
              .catch(err =&gt; {
                  commit('auth_error');
                  reject(err)
                  })
              })          
  
      },
  }
  </code></pre>