Hasan
Hasan

Reputation: 95

PHP Prevent Session Data Sharing between applications

How to prevent session from being shared in all of my applications.

I'm using xampp, so if i have a session['key'] = 'value' in app A I can't get it in app B.

How to separate session for each application?

Upvotes: 2

Views: 249

Answers (2)

xkothe
xkothe

Reputation: 674

You can use

ini_set("session.save_path", "/your_home/your_sessions/");

to set the current session file in your server. Or you can define a domain for the session cookie, like so:

ini_set('session.cookie_domain', '.example.com' ); 

And then, just start it as

session_start();

Upvotes: 1

Simone Nigro
Simone Nigro

Reputation: 4887

in app A

session_name('sessiona'); // SessionA
session_start(); 

in app B

session_name('sessionb'); // SessionB
session_start(); 

read session_name()

Upvotes: 1

Related Questions