Jump to content

Session handling in combination with API bootstrap


Rob
 Share

Recommended Posts

I'm using PW as a back-end but bootstrapping within a separate Silex site. So basically I have a totally separate site, I bootstrap the API by including the PW index.php then I use the API to grab my page data and do whatever I want with it.

I'm trying to utilise Silex's session handling ability to store session in a DB for stuff like a shopping cart. Unfortunately it seems that's there's some sort of clash between the session handler registered by PW and the one registered by Silex. I've spent a lot of the afternoon reading around the subject and it seems like it's one of two outcomes; Either the two systems of session handling can be made self-contained from one another by each choosing a good time to call session_write_close() or it simply isn't possible to have two clashing sets of session handlers because the first "locks" the session data.

I wonder if Ryan knows where it might be possible to add the session close code to make sure that PW only has it's handle on the session for the time it needs, or not at all when it's being accessed only via the API. I wonder if PW doesn't need to utilise any session handling at all if it's being used via bootstrapping, although I suppose that's probably a massive simplification of what is happening under the hood!!

Any help gratefully received as I'm sure it should be possible to get these two nice platforms working together in sweet harmony.

For anyone interested I'm trying to use PdoSessionHandler code as demonstrated here: http://silex.sensiol...on_storage.html

Link to comment
Share on other sites

ProcessWire's session handler is just sitting on top of PHP's, so you should be able to close it down using traditional PHP functions after bootstrapping ProcessWire. I'm thinking that if you can close it down before initializing the Silex one, that may work. If that doesn't do it, you could try to prevent PW from initializing a session by temporarily removing it's write access to /site/assets/sessions/ (before bootstrap), then enable write access again after bootstrap... a bit of a hack, but just trying to find something that might solve it. So long as debug mode isn't on, I don't think you'll see any errors. Btw, by "bootstrap" I just mean the include("/path/to/pw/index.php").

We're going to be supporting DB-based session storage very soon here (hopefully 2.3), and I'll look into providing the option of disabling PW's session handler entirely when adding that.

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...