I wanted to know is it a good practice to use SQLite as a main session storage or at least as a backup session storage with primary memcached?
Could you give me some pros and cons?
(I am building a MVC Framework for education purposes and was thinking of different possibilities and implemetations)
The session extension provide a mechanism for recording changes to some or all of the rowid tables in an SQLite database, and packaging those changes into a "changeset" or "patchset" file that can later be used to apply the same set of changes to another database with the same schema and compatible starting data.
Android provides several ways to store user and app data. SQLite is one way of storing user data.
An SQLite extension is a shared library or DLL. To load it, you need to supply SQLite with the name of the file containing the shared library or DLL and an entry point to initialize the extension. In C code, this information is supplied using the sqlite3_load_extension() API.
By default, session data is stored in the server's /tmp directory in files that are named sess_ followed by a unique alphanumeric string (the session identifier).
SQLite Pros
SQLite Cons
Even Better Solution - Memcache
Since sessions are usually accessed with every page hit it would make sense to use the fastest mechanism possible without all the overhead of a database layer while still allowing it to work in a distributed system (multiple PHP servers for example).
Use Memcache which is well tested with PHP and you can even integrate memcache sessions just by modifying a few php.ini settings or for more fine grained control (or to use other software like redis) you can create your own custom session handler.
This has different pros and cons
Memcache Pros
Memcache Cons
Though you should be using other software that monitor both those things or write a cron job script that checks the memcache service is still running - but thats another question and answer for another day. Point is, those cons can be lessened to some degree.
Further reading on the topics covered
Sessions based on files are a bad idea, because the file will be locked if you dont close the write access to the session ( session_write_close(); ). But why should you limit yourself/theServer when you just have to use sqlite to avoid this problem?
so sqlite pro: - easy to use (change php.ini config):
session.save_handler = sqlite
session.save_path = "/path/sessions.db"
sqlite con
i would like to use apc, but then i need to implementation and i'm worried that it could end in security issues...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With