Jump to content

Too many sessions!


xcandiottix

Recommended Posts

session_save_path("/home/content/q/1/w/q1w2e3r4t5y6u7/html/tmp/");
session_start();

 

I have this at the head of my index page. I'd like to count how many files are in temp to find out how many users are online. After going to my index page, i checked how many users were online via the script I wrote and it said 1. I refreshed the page and it said 2. It went as high as 10 with each refresh and then I stopped because something isn't right. I checked my temp folder and there are 10 temp files. How can one page visitor start so many unique sessions? Is there a way to prevent this? I'm using the session start command with dual purpose. One, if a user loads the page. Secondly, to check if $_SESSION['active'] exists so I know this is a registered user. How can i limit the amount of sessions started by an unknown user and efficiently count how many files are in the temp directory?

Link to comment
https://forums.phpfreaks.com/topic/211236-too-many-sessions/
Share on other sites

you can look into storing your sessions in a database rather then on the server. Its especially a good idea if the site your making is going to get so heavy traffic wise and user base wise that you will eventually need to cluster servers to run the site, and storing sessions on a single server in a clustered arrangement just wont work well.

Link to comment
https://forums.phpfreaks.com/topic/211236-too-many-sessions/#findComment-1101471
Share on other sites

Some reading I came across had counting session files performing at 19% faster then a database method. I don't know if this is correct information or not but it said in a multi-user situation that a file count would be preferred due to the speed factor. Have you come across anything about that? This article could have referred to an old version of php perhaps.

 

As for my sever I am using a linux grid server provided by godaddy if that makes a difference.

 

Thanks for the reply.

Link to comment
https://forums.phpfreaks.com/topic/211236-too-many-sessions/#findComment-1101473
Share on other sites

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.