Because I have two websites on the same server and domain (different folders) and I have problems when asking for $_SESSION['id'], basically both sites are using the same value and I don’t want that.
If I change domain and point it to the same folder on the same server, will I have the same problem?
Session data is stored on the server. A cookie with the session’s ID is stored on the user’s computer, and is associated with a single domain name. The browser passes this cookie to the server so it knows what session data to associate with the user.
Two websites, hosted under the same domain, are going to share the same session because there will only be one cookie containing a session ID. If you put the websites under different domains, you will no longer have the problem since two different cookies (containing two different session ID’s) will be made on the user’s computer; one for each domain name.