r/PHPhelp • u/[deleted] • Nov 14 '15
Should I avoid session variables?
So I've been learning PHP in school, and our teacher really, really likes session variables. However, I have a web developer friend who says you shouldn't use session variables because...
As a rule of thumb, storing things in the session is discouraged, because it does not scale well (the server runs out of session storage). Ideally your design should be stateless on the server. i.e. no session data.
Since I'm really new at this, do any professional developers on here have a stance on this issue?
8
Upvotes
1
u/[deleted] Nov 14 '15
I'd agree with your friend but make sure to acknowledge the first part of it, it's a rule of thumb. Whether or not sessions are appropriate completely depends on the problem you are trying to solve but if you do decide to use them, it's something that you should probably think about fully and understand the potential problems and limitations you might face.
What is your teacher using sessions for?