Robin S Posted June 20, 2019 Share Posted June 20, 2019 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? 1 Link to comment Share on other sites More sharing options...
dragan Posted June 20, 2019 Share Posted June 20, 2019 Can't you use one of these? $_COOKIE["wires"]; $_COOKIE["wires_challenge"]; Seems like the first one is always created, and the second one only if logged in. 3 Link to comment Share on other sites More sharing options...
teppo Posted June 20, 2019 Share Posted June 20, 2019 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 ? 1 Link to comment Share on other sites More sharing options...
Robin S Posted June 21, 2019 Author Share Posted June 21, 2019 Thanks for the replies. It's no problem to me to use the built-in PHP functions - just wanted to check I wasn't overlooking something. Link to comment Share on other sites More sharing options...
cpx3 Posted August 6 Share Posted August 6 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 More sharing options...
da² Posted August 6 Share Posted August 6 @cpx3 You store the products in the session or a cookie, you don't need the session_id to do that. 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted August 6 Share Posted August 6 2 hours ago, cpx3 said: How would you do a shopping cart if not with the session_id? I set one myself, like so (from within a module): $this->wire('session')->set('cart', $cart); 1 Link to comment Share on other sites More sharing options...
cpx3 Posted August 7 Share Posted August 7 A million thanks, that is indeed much easier! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now