Jump to content

Get a unique identifier for the current session?


Robin S
 Share

Recommended Posts

I was looking at the API docs for $session and couldn't see any way to get a unique identifier for the current session. I want to use this to create a name for a temp directory so that paths for files stored there for each visitor do not clash with each other.

I can use PHP's session_id() function but I'm surprised there's no ProcessWire $session method for this. Does anyone know if there is a PW way to get an identifier for the current session that I'm missing?

  • Like 1
Link to comment
Share on other sites

8 hours ago, Robin S said:

I can use PHP's session_id() function but I'm surprised there's no ProcessWire $session method for this. Does anyone know if there is a PW way to get an identifier for the current session that I'm missing?

ProcessWire uses session_id() internally as well (in SessionHandlerDB), so by all means use that.

I've never had any reason to actually work with session ID's in ProcessWire or heard anyone else asking for this, so my guess is that it's not a very common need, and as such Ryan hasn't felt the need to include a custom getter method for it in the Session class ?

  • Like 1
Link to comment
Share on other sites

  • 5 years later...
On 6/20/2019 at 1:06 PM, teppo said:

ProcessWire uses session_id() internally as well (in SessionHandlerDB), so by all means use that.

I've never had any reason to actually work with session ID's in ProcessWire or heard anyone else asking for this, so my guess is that it's not a very common need, and as such Ryan hasn't felt the need to include a custom getter method for it in the Session class ?

@Teppo: How would you do a shopping cart if not with the session_id?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...