Is this bad practice/can cause problems?
$_SESSION['stuff to keep']
As opposed to calling str_replace() on the indices.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is bad practice, but not because of the space.
Here, your code is silently misbehaving, and the bug can take a while to be found. Good practice is to use a PHP-enforced name, such as a class constant:
You may then define that constant to any constant you find interesting or readable, such as
"stuff to keep"(with spaces). Of course,extract()and casting toobjectwon’t work anymore, but you shouldn’t be doing that anyway with your session.Allowing user-entered text into session keys is, of course, a blatant security fault.