You can avoid creating a session every time. So what if session files are small? Why spill them when it is not needed?
Here is what I am doing essentially:
Check for a session cookie on the incoming request and only session_start() if you received it.
Registered users browsing the site (usually) will not send session cookies, so they will not run session_start() . Plain.
As soon as someone logs into your site and you want to start a session (a session both logically in your application and in the sense of PHP), use session_start() , etc., which will handle the cookie setting.
And as soon as someone logs out, make sure you also destroy the session cookie, not just the PHP session itself.
Obviously, the user can block your cookie operations from endings and damage them, but they can do it anyway.
source share