Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP $GLOBALS | Security enquiry

I have a settings.php page in my application which uses $GLOBALS to store configurations used in the web app.

As an example, he is a sample setting variable I use:

$GLOBALS["new_login_page"] = 1;
$GLOBALS["secret_cross_check_token"] = 3243242342423;

I then call those globals on other pages (hence why I use $GLOBALS), to perform tasks, such as give a user a new feature if they have that global toggled to 1.

The Question:

This works really well for me and i do not wish to use a database to store them, however recently I came to think, are $GLOBALS secure? Can a user read or manipulate them? If yes, what is the solution???

I understand it is server side but i just had doubts as to whether the user can somehow access the $GLOBALS

like image 635
user3495256 Avatar asked Jan 27 '26 12:01

user3495256


1 Answers

A globals variables can only be accessed server side, you can use them safely.

If an user can access your globals variables it's because he has gained access to execute code in your server, so, in this case, he can do a lot of more things than read your globals variables.

If an user can execute code in your server, he will be able to copy all your files and all your database easily, so the access to global variables would not be the major problem.

like image 71
David Rojo Avatar answered Jan 30 '26 16:01

David Rojo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!