I suspect this must be obvious, but Googling "UID" and "PHP" isn't very easy...
I have a PHP script which calls an executable which needs a whole bunch of values saved from call to call. This would logically be a session, however, it's going to be a major job to extract all the values from the exe to use the session functions in the PHP. So I thought what I'd do is set up a session in the PHP, pass its UID to the executable, and use it as a filename to read and write the (several hundred, maybe more) required values inside the executable. That way, if and when we move to a more modern setup, I can add to the PHP session rather than having to rewrite the entire logic.
So, having called session_start(), is there a variable just sitting somewhere which contains the value of the UID which that session has been allocated? Or did I miss something and it's up to me to compute the UID? I got the impression that it's generated automatically.
Apologies for newbie question if this is obvious.
Actual value of a session UID?
Moderator: General Moderators
Re: Actual value of a session UID?
Are you looking to return the auto generated session_id that session_start generated?
if so you could call it like so
If your looking to be able to recall a SESSION id that may of bee auto generated a while ago, you would need to store these session_ids as they where generated in a Database or a FileDB..
An Example of this would be:
if so you could call it like so
Code: Select all
session_start();
$sessionIdVar = session_id();
echo $sessionIdVar;
An Example of this would be:
Code: Select all
session_start();
$sessionIdVar = session_id();
echo $sessionIdVar;
// Write the session_id() to a mySQL DB
// Setup a Tabel That looks like
// ID | DateCreated | SessionID
// And have the Session write to it everytime its created
// You can then recall this later down the road by ID and use the SessionID the database holds to get to your file.
Re: Actual value of a session UID?
session_id is exactly what I need. Many thanks guys - I think I was failing to find it because everything else I'd read referred to the ID with a U on the front.
I don't even need to recover old sessions. Just to know what the current one is.
I must say, this is a super-helpful forum.
I don't even need to recover old sessions. Just to know what the current one is.
I must say, this is a super-helpful forum.