Jump to content

to session or not to session


Recommended Posts

On a site like facebook, where they must make tonnes of sql statments on each page.. do you think that they for example

check to see if you are friends with a user on each page.. or do they do it just once and store the result in a session...

obviously it makes sense to store it in a session.. however it is easier to just do the request 'see if they are friends' on

each page rather than having to check if sessions exists.. and if the session is for that friend... etc.

Link to comment
https://forums.phpfreaks.com/topic/161949-to-session-or-not-to-session/
Share on other sites

I would imagine that a site as big as Facebook would be using sessions that are stored inside a database, and not on the filesystem.

 

I've done this before and found that it's not that big a performance issue, providing you use proper indexing.

 

<?php
if($logged_in){
    $are_friends = $user->are_friends($_GET['uid'],$_SESSION['user_id']);
}
?>

I would imagine that a site as big as Facebook would be using sessions that are stored inside a database, and not on the filesystem.

 

I'm pretty sure they would be using something like memcached. You should be fine storing the session data in a database. The forums a main site here do that actually.

Man. I can't even imagine the extent of the performance issues that Facebook runs into daily. Their source was leaked a while ago. Server error or misconfiguration dumped all the code on the login page. Although it didn't reveal the inner workings, it did look as if they were using Smarty - or some sort of custom template system.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.