0
votes

I've tried this:

session_name('mys1');
session_start();
var_dump($_SESSION);

session_name('mys2');
session_start();
var_dump($_SESSION);

but both var_dumps dump the session 'mys1' data.

I've also tried putting a session_destroy() in between:

session_name('mys1');
session_start();
var_dump($_SESSION);

session_destroy();

session_name('mys2');
session_start();
var_dump($_SESSION);

that actually var_dumps the two different sessions correctly but after that the 'mys1' session is gone.

2
learn what session_destroy(); function do..? what session_destroy(); function do is its destroy the session from the script.Dipesh Parmar

2 Answers

0
votes

You can try to use different cookies for these different sessions.

When you call session_start() a cookie is created for that session.

Try to do session_id($_COOKIE['session_two']); before the second session_start() to jump to the correct session id

0
votes

Use session_write_close instead of session_destroy.