PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Nov 21, 2014 9:46 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Sun Jun 26, 2011 5:45 am 
Offline
Forum Newbie
User avatar

Joined: Thu Sep 02, 2010 12:36 am
Posts: 13
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.


Top
 Profile  
 
PostPosted: Mon Jun 27, 2011 9:44 am 
Offline
DevNet Evangelist

Joined: Tue Dec 21, 2004 6:00 pm
Posts: 6259
Location: Winnipeg
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


Top
 Profile  
 
PostPosted: Mon Jun 27, 2011 1:10 pm 
Offline
DevNet Master
User avatar

Joined: Mon Feb 24, 2003 11:12 am
Posts: 2572
Location: The Republic of Texas
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.


Top
 Profile  
 
PostPosted: Mon Jun 27, 2011 1:31 pm 
Offline
DevNet Master
User avatar

Joined: Sun Feb 15, 2009 12:08 pm
Posts: 2775
Location: .za
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.

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.

_________________
“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


Top
 Profile  
 
PostPosted: Mon Jun 27, 2011 3:29 pm 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4294
Location: Sofia, Bulgaria
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.


:D
viewtopic.php?f=1&t=82659&p=460330#p460330

_________________
Image
http://openfmi.net/projects/flattc/ Linux is better :)


Top
 Profile  
 
PostPosted: Mon Jun 27, 2011 3:31 pm 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4294
Location: Sofia, Bulgaria
alex.barylski wrote:
Files are more risky on shared servers


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.

_________________
Image
http://openfmi.net/projects/flattc/ Linux is better :)


Top
 Profile  
 
PostPosted: Mon Jun 27, 2011 4:53 pm 
Offline
DevNet Master
User avatar

Joined: Sun Jan 21, 2007 12:06 am
Posts: 4135
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group