Question : How to reset PHP Session Handler to default

I have a problem that I have encountered trying to implement authentication with a Joomla plugin.

The plugin itself has a file-browser that is completely separate to Joomla (i.e. outside the API and independent), but I need to only allow access to authenticated users.  This in itself is easy enough, as I can fire up the Joomla framework and query the user.  This works fine.  However, on subsequent calls to the page, I want to be able to use a session variable to confirm the user is authenticated without having to fire up the Joomla app again.

The problem is that Joomla uses a custom session handler.  What this means is that when I save the session variable after authentication, this variable is going into the Joomla database session.  When I then query this on the next page load, I am querying the standard PHP session (without any custom handlers).

So, I need to be able to write to a standard PHP session AFTER the session handler has been overriden by Joomla.  Essentially, I need to be able to switch back to standard handling - but I can find no way to do this.

Anyone any ideas?

Answer : How to reset PHP Session Handler to default

I couldn't use it, that was the point - Joomla uses a Session object and the database, but I needed simple sessions without Joomla.

Anyhow, I have finally worked it out.  The code below will end any current session and set the session handler back to default.  It will then open the session.  Strangely, I'm sure I tried this before without success, but it now works perfectly.


1:
2:
3:
@session_destroy();
ini_set('session.save_handler', 'files');
session_start();
Random Solutions  
 
programming4us programming4us