PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 15, 2022

[FIXED] How can get the data from the local storage every user's login in laravel 6?

 November 15, 2022     laravel, laravel-6, local-storage, php     No comments   

Issue

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


Solution

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> 


Answered By - Saleem
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing