Home > Blockchain >  Can PHP superglobals be changed or appended with another variable?
Can PHP superglobals be changed or appended with another variable?

Time:10-21

I'm wondering if I do something like $_SERVER['myVar'] = "myValue", does it change in other sessions? Could I access that custom variable from other sessions?

CodePudding user response:

I'm wondering if I do something like $_SERVER['myVar'] = "myValue", does it change in other sessions? Could I access that custom variable from other sessions?

No.

PHP doesn't provide a location to store information that should be shared between multiple visitors to a website. (It has $_SESSION for data that should be shared between multiple requests from the same visitor).

The usual way to share data between users is to use a database. A file on the filesystem is another option, but databases solve a lot of problems (race conditions, locking, etc) for you.

  • Related