Hi, guys,
as the topic as i said, which better to save the session data, default method in php is file storage .
what do you think about this question.
Store session, file , database, memory, which better
Moderator: General Moderators
- coolesting
- Forum Newbie
- Posts: 13
- Joined: Thu Sep 02, 2010 12:36 am
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Store session, file , database, memory, which better
There is no "better" only different. DB hosting is probably more secure and robust and scalable if configured properly. Files are more risky on shared servers, but require no additional implementation or library.
Cheers,
Alex
Cheers,
Alex
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Store session, file , database, memory, which better
Also, suppose you want to display how many users are online or the usernames of the users online, etc. I don't know how you can achieve this with the file based sessions, but with a DB it is just a simple query.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Store session, file , database, memory, which better
Out of curiosity: wouldn't an SQLite file-based database be able to do this? I think if a choice has to be made, go with databases, in the long run it will probably save you a lot of hassles.AbraCadaver wrote:I don't know how you can achieve this with the file based sessions, but with a DB it is just a simple query.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Store session, file , database, memory, which better
AbraCadaver wrote:Also, suppose you want to display how many users are online or the usernames of the users online, etc. I don't know how you can achieve this with the file based sessions, but with a DB it is just a simple query.
viewtopic.php?f=1&t=82659&p=460330#p460330
There are 10 types of people in this world, those who understand binary and those who don't
Re: Store session, file , database, memory, which better
One just needs to set the session files save path (if it isn't already set by the hosting company) to a path in his/her own directory in order to get fulll privacy.alex.barylski wrote:Files are more risky on shared servers
There are 10 types of people in this world, those who understand binary and those who don't
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: Store session, file , database, memory, which better
But the database is still more powerful since you have the ability to precisely control the death of those sessions. PHP holds onto session data past the expiration and is as limited as the GC.
Database is my personal preference, but it is also the slowest. Memory is the fastest to access, though it requires a bit of extra logic to set up and, AFAIK, has difficulty working on shared servers. The reason that the file method is the default is because it's a stable medium.
Database is my personal preference, but it is also the slowest. Memory is the fastest to access, though it requires a bit of extra logic to set up and, AFAIK, has difficulty working on shared servers. The reason that the file method is the default is because it's a stable medium.