avasin
avasin

Reputation: 9726

Is it possible to load session by SID in php?

I am working on API, where by default cookies are used, but also should be possile to load session data by sid.

So, scenario looks like the following:

  1. Client makes a request with a cookie and/or with SID parameter
  2. We check, if SID is defined - we load session data by SID
  3. If SID is not defined - we use SID, that is defined in a cookie

My first idea was to use session_id() function to load session data for specified SID, but i found that this function does not do this - it just overwrites current session id, but does not load any data for specified SID.

Is it possible to load different session in PHP for different SID?

Upvotes: 2

Views: 906

Answers (1)

troelskn
troelskn

Reputation: 117547

You need to use session_id before you call session_start

Upvotes: 4

Related Questions