I have 2 php based pages that I want to keep session variables in so I call session_start() before any code on both pages but session_id() still shows different ids for each site after my redirect happens, and my session variables are not stored either. Does infinityfree not support sessions or is there something else I need to do? The sessions work on my localhost.
Without more info we can’t really help you. Can you share your URL and the PHP code?
You say it shows different IDs “for each site after my redirect happens”. What do you mean by “site” exactly in this context?
PHP session cookies are linked to the specific domain name, and will not be sent to any other website. Being able to access session cookies from other websites would be extremely bad for security. So it’s not possible to use sessions across different domain names.
So I can’t save login information across different website names? What about subdomains?
It is the same:
In this case, a subdomain is treated the same as a regular domain. If you put a star in front of the domain (eg. *.rf.gd), it would either work for all subdomains of rf.gd (which is a horrible security exception) or it would refuse it.
In short: No, it’s not possible.
Cookies can be shared among subdomains, but the cookies set by PHP sessions do not have this configuration. You could roll your own session implementation with cookies set on the same base domain, but that’s more involved than simple PHP sessions.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.