PHP: what is the purpose of session_name

I’m not quite sure what the purpose of session_names is..
Can someone please explain in what circumstances defining a name would be beneficial?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

You have two sites on the same domain. (say, a blog and a forum)

They both run different pieces of software.

If they ran on the same session and used the same variables in $_SESSION, (say, user_id), they would conflict.

session_name lets you give each application a different session.

Solution 2

The default is – I think – PHPSESSID. If you have more than one application on the same host, they would share those sessions. So, you should set different session names for each application, so that there is no weird stuff happening.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply