2

I want to condition the login redirection of user if the data of local storage is true or false,. example: if data is true,.. it will redirect it 1st page, else it will redirect it in 2nd page? Is their a laravel command or php command to get the values/data from local storage?

sorry for my english, i hope some one can help,. thanks

2 Answers 2

3

Laravel is build on PHP is server side language and there is no option to check the localstorage that is client side on server to load view. You will need to check the localstorage data in the view file and then redirect to the page as you need. Something like

<script>
   var user = localStorage.getItem('user');
   if(user){
      window.location.replace("http://stackoverflow.com/user_profile");
   } else {
      window.location.replace("http://stackoverflow.com/login");
   }
</script> 
1

Local storage is stored on the client side, so Laravel can't access it. You'll need to use JavaScript.

This is a similar question for an older version of Laravel, but it should help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.