I can do more one session in just one site? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I can do more one session in just one site?

25th Apr 2016, 4:11 AM
Vinícius Vilela Nunes
Vinícius Vilela Nunes - avatar
2 Answers
+ 5
Yes! You can use multiple session_start(); statements and use the session_id(); function to distinguish between different sessions. For example: <?php //Start first session and set a value session_id("session_A"); session_start(); $_SESSION["name"] = "A"; session_write_close(); //Start second session and set a value session_id("session_B"); session_start(); $_SESSION["name"] = "B"; session_write_close(); //Get the values session_id("session_A"); session_start(); echo $_SESSION["name"]; session_write_close(); session_id("session_B"); session_start(); echo $_SESSION["name"]; session_write_close(); ?>
6th May 2016, 9:50 AM
James Flanders
+ 1
Yes
4th Sep 2016, 12:40 PM
Vishal Prajapati