For my project I use cookies to automatically log in users. However, I don't want the user to know which cookies are used for what purpose.
For this reason I decided to encrypt the names of the cookies, as well as the content. Decrypting the content of these cookies for use does not cause much trouble. It works perfectly as I want it to. However, for the sake of compatibility and dynamics, I tried to call the cookies dynamically by their names, using similar code like this:
if(isset($_COOKIE[$encryption->decrypt('username')]){ ... }
But this did not seem to work. Neither did setting a variable with the encrypted name of the cookie, like this:
$cookie_name = $encryption->decrypt('username');
if(isset($_COOKIE[$cookie_name]){ ... }
The way I am currently using this script (which works, but seems a bit sloppy) is like this:
if(isset($_COOKIE['Nm9yNCtoK1lTY2M5TnhKWnRvL0NjUT09']){ ... }
Is there a way to do this correctly, or am I forced to call the cookie by it's pre-encrypted name, like I currently do?