I have a website. People can login it on here
sub.domain.com
If they login here, the session will do its job and user will be logged in. On any page at sub.domain.com, the session value be will returned so it will work fine.
But site can also be reached from http://www.sub.domain.com . When user logins at sub.domain.com, the session value is empty at http://www.sub.domain.com.
I mean if user logs in at sub.domain.com,
When he navigates to http://www.sub.domain.com, site will say ‘please login’, but user was already logged in at site without ‘www’.
Hope it was all clear, thank you.
Add in your main script at the top, before session_start.
If you running PHP with suhosin enabled, try disabling there settings too
Source PHP bug tracker
Thanks to @RandomDave