0

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.

1
  • learn what session_destroy(); function do..? what session_destroy(); function do is its destroy the session from the script. Commented Aug 21, 2013 at 5:33

2 Answers 2

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

i tried calling session_id() but it didn't have any effect.
0

Use session_write_close instead of session_destroy.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.