search

Home  >  Q&A  >  body text

How to write a statement in laravel to determine the expiration of a logged-in user's session?

How to write a statement in laravel to determine the expiration of a logged-in user's session?

There is an ajax request that can return data when the user logs in. When the session expires, it will jump to the login page. How to do this?

 axios.get('/admin/articles')
      .then(response=>{
          console.log(response.data);
      })
      .catch(error=>{
          console.log(error);
      });
PHP中文网PHP中文网2745 days ago881

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-07-04 13:47:48

    Expired, will return 401 status code

    By default, axios will throw 401 to error. You can handle the 401 status code in catch and jump to the login page.

    reply
    0
  • Cancelreply