If you are a developer you may need to work in different environments like dev, test, prod etc. You will be liking if you can share sessions among different sub domains. For example, if you share sessions you need to login only on one environment, say dev environment, it will automatically login to test environment. You can achieve this if you could share sessions among sub domains. As we know, we need to start session in every pages to use session variables. Just add a bit of code above session start as below.
// This could be common name
$session_name = session_name("session_name");
// This should be your domain name not sub domain
session_set_cookie_params(0, '/', '.yourdomain.com'); session_start();
You are done. Please don’t forget to add these codes in every pages where you want to share session variables.
Hope you like it. Please feel free to contact me if you have any queries – firstname.lastname@example.org