Reputation: 1171
I'm working on some website where I need to load session library, but it must be limited only to places on website where it's really useful, not on all. After all that means, the session library must not be loaded on index page. But there is a problem because on index page I need to display user's data if the user is logged in. What can I do to check if the user is logged in, without loading session library or not creating session cookie on index page?
Upvotes: 1
Views: 670
Reputation: 4967
You can't check whether the user is logged in or not if you don't have an active session on your index page.
Your session must exist in every part of the system execution.
Make the session handler always be available but limit the information you store in the sessions instead of limiting locations in the system of where to use sessions at all.
Upvotes: 2