Home > Software design >  How can I hide user id in the url
How can I hide user id in the url

Time:11-05

How can I hide the user id in the url using php?

I have a button with the user id:

<a href="edit.php?id<?php echo $row['user_id']; ?><button>Edit</button></a>

How can I hide or better encrypt it?

CodePudding user response:

use flash session instead of $_GET parameters flash session is once set and when reading session destroy ownself

for example in laravel

return  redirect()->route('ffaa')->with('id',12);

here with method sends data to another page using flash session

CodePudding user response:

You can encrypt User ID in href

<?php $user_id = md5($row['user_id']); ?>
<a href="edit.php?id=<?php echo $user_id; ?>"><button>Edit</button></a>

and on edit.php page you can validate it using same encryption method, like:

<?php 
   $user_id = $_GET['id'];
   if($user_id === md5($row['user_id'])){
       // Code user id matches.
   }
?>
  •  Tags:  
  • php
  • Related