I’m trying to set up a local MAMP PHP development environment to develop a PHP web application for deployment on an Apache web server. The web app spans several subdomains, with one subdomain, “portal.” handling user accounts, logins, etc.
The user portal uses PHP Session variables, as well as cookies, to mark a user as logged in, and several of the subsequent methods rely on the user’s logged in status (checked using the session variable and cookies).
The problem is that the cookies and Session variables set on the Portal subdomain don’t seem to be shared across the whole site. Everything works fine on the web server, but on my MAMP environment the cookies and Session variables appear unset outside of the subdomain where they are initially set. This is not the case on the web server, where the cookies and Session variables appear to be shared across the entire site.
I’ve tried this using both localhost and a local development domain (e.g. “portal.domain.test”) set up through my hosts file. I’m using Apache vhosts for subdomains the same as I am on the web server.