Welcome Guest, Not a member yet? Register   Sign In
Session Handling: Which Should I Choose?

Eh... There is no user interaction with the session table, and the session library uses active record, which protects all your queries against SQL injection attacks by a proper escape mechanism. No need to do that yourself, that's the advantage of using a framework.

Especially for small sites the database solution is a lot better then PHP's native sessions, as the database engine is a lot more effecient in I/O then PHP's file I/O code. Also, all keys will be in memory, so it's going to be fast.

And you know what you should do with rumours...

Sessions work very reliably, I've got sites serving over 2 million pages (13 million hits) per month, and approx. 20.000 users registered. Which means a highly active session table. For high-volume sites, I have modified the session library slighly. Default, every set_userdata() call results in an update query. Which I switched off, I do a manual sess_write() when I reach the end of a page request, or just before a redirect(). For low volume sites, this is not an issue at all.

That's a fantastic response, WanWizard! It's changed my mind and my perspective. Thank you!

[quote author="WanWizard" date="1282099506"] the database engine is a lot more effecient in I/O then PHP's file I/O code. [/quote]

you might be kidding here Smile
file reading slower than running SQL query ? Smile do you understand that database/table any ways stored in files and MySql is kind of intermediary ? Smile

more over highly visited sites makes sessions table reindexing all the time and as higher load as higher database load ... if table engine MyISAM then we have table locks = queue
if InnoDB = slower updates/inserts

and you still wanna say that storing sessions in DB is more efficient way than native sessions ? Smile
you will never make me believe that use of intermediary + slow all the time updates and inserts (with the use of already loaded mysql with other queries) could be faster than just separate read and write to file by file name Smile

storing sessions in the database cant be faster than native php sessions Smile

Theme © iAndrew 2016 - Forum software by © MyBB