I am trying to set up a login system for my website that requires someone to be logged in in order to post. I have set it up with sessions and it works great on my localhos
The only time I´ve had a similar problem, was when I was accidentally changing the domain while going to another page (from www.mydomain.com tomydomain.com and the other way around).
You can have your session persist between different sub-domains using session_set_cookie_params():
session_name('login_session');
session_set_cookie_params(0, '/', '.mydomain.com');
session_start();
Edit: Perhaps this can help you: A very interesting article: PHP Session Debugging