Assume that there is a PHP variable:
$variable = 'username';
cookie value = 'username'
Which one is better to access? get_cookie() or just use $variable?
I have a lot of code using get_cookie('cookie_name') (a CodeIgniter function) instead of using variables.
Will it increase performance if I change it to access $variable instead of cookie?
Cookies are passed from the user’s browser to the server every page load, whether you use them or not.
There’s really going to be very little performance difference.
What you may want to investigate is whether the data that is being stored in cookies (if you say it’s a lot) should be there or not. Many people have cookies turned off, so you only want to store nonessential information (and information that doesn’t have to be secure) in them.