Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using session_start twice [duplicate]

Tags:

php

session

I have a pretty dumb question (I believe):

What would happen, if I were to start 2 sessions, calling session_start() twice? For example, I have a class User, where I start user's session, and a class Error, in which I start another session, so I can store errors and notifications in them and pass them to other pages.

Could I run into a problem, and is this efficient?

like image 775
Gregor Menih Avatar asked Oct 17 '12 17:10

Gregor Menih


1 Answers

PHP doesn't support multiple simultaneous sessions. Calling session_start() a second time in a request doesn't do anything unless the existing session was destroyed (via session_destroy()).

session_start() creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie.

http://php.net/session-start

like image 62
Amber Avatar answered Oct 05 '22 22:10

Amber