Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 2
    More reason why these kinds of globals should go away replaced with objects/methods that can be called on to get them when necessary. Why does setcookie exist, but we get cookies via $_COOKIE? Also, since $_COOKIE is only set when the current session starts, and is never updated, it requires that you alter/set cookies in both areas so that later areas of the code have up to date information. Commented May 13, 2011 at 5:03
  • Thanks James, I've been offline for a while so I couldn't respond. To make a long story short - I agree with you. There's always a better solution than writing to post/get/etc, but I'm still not sure if it's considered a strictly bad idea, as in "never do this ever". So, if I come across this type of code again, do you think I have a right to "call them out" on sloppy code, or can this be used in a clever, safe way sometimes? Commented May 14, 2011 at 11:45
  • @Wesley If it would be "never do this ever" the superglobals would be probably strictly read-only - they are not. I'd just call it bad practise to set or overwrite them in your application code - for said reasons. Commented Feb 6, 2014 at 19:20