We may be at crossed paths...  I'm wanting to save the :memory: database to
the session, not the other way round, so that when the 2nd page loads, the
:memory: database can be recreated and available as it was on the last page
load. The advantage is that after some time, the session is deleted
automatically by the server and the database goes with it, so short term,
high-intensity data can be stored and queried quickly in :memory: and the
add/edits remain through the entire user experience. An alternative is to
use a file based database per user, but this would require a tidy-up routine
to be manually coded, and makes the code less portable.

An alternative is to create the :memory: database and populate it from
session data each time, then save back to session on script close. Not as
swift or elegant, but if it's the only way then that may be that!



---

> Hi there,
>
> I have a need to create a :memory: sqlite database, but save it into the
> user session (PHP) but can't see a way to access the data to save. Looking
> for a sqlite version of serialize() I guess.
>
> Has anyone managed to do this? Is it even possible?
>
> Wanting to be able to maintain a large chunk of data across a users
session
> on a website, and the array's are getting tedious to manage and search
> through!

The PHP session information has to be persistent, so it's not going to be
easy
to use a :memory: database.  There is lots of information about how to save
session information to a database, though, on the PHP web site.  I haven't
looked at it in a couple of years, but I'd guess that you'll get some good
pointers if you look at the documentation for session_set_save_handler().

Also, IIRC, PHP provides functions to do serialization.  You won't need them
if you go the session_set_save_handler() route, but if you want to serialize
data yourself, those functions should be available.

Derrell

Reply via email to