Why does my session not work when I visit mywebsite.com vs www.website.com. It works if I go to www.website.com. I have a script setup on page 2 that our forms takes the visitor into. On page 2 it is a https. I am using a header redirect on that page. It redirects if a session is not set. The problem is it always redirect back into page 1. However if I go to page 1 using www.mywebsite.com the session starts and assigned the proper variable just fine. If I go to mywebsite.com then submit the form to page 2 it redirects?
if you assign the session to www.mywebsite.com and then send a user to mywebsite.com it will not transfer the session because it sees them as two different domains Edit: or the same thing the other way around
I'm not sure, but you can try to store the session in the database or in a page session.php (call the session.php each time on new page)
That's interesting, where does it say that in the PHP manual though? By the way I setup a .htaccess to just redirect any non www. to www.mydomain.com
I don't believe it is in the php manual. To me it's just common sense that www.mydomain.com is different from mydomain.com. Think of the www as a subdomain. If you look at dns configurations you will see that the www is added. Someone else could probably explain this better.
It's common sense. As a webmaster you have to decide to use www. only, or non-www only. I prefer the last one.
A session can't be transferred from one domain to other domain. If need to do this then you have to store you the session_id in you db and then redirect it to the other domain with user_id. As you arrives in 2nd domain, then you need to fetch the user_id and check the db is session is selected or not. After that you can go on with your job.