Jump to content

Recommended Posts

Posted

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
Posted

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.

  • Like 3
Posted
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
Posted

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.

  • 5 years later...
Posted
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?

Posted
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);

 

  • Like 1

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
  • Recently Browsing   0 members

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