Jump to content


Photo

Lots of Sessions


  • Please log in to reply
10 replies to this topic

#1 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 02 April 2012 - 01:42 PM

Hi folks

So I've got a very active PW site up and running (finally) but I'm not ready to link to it until I finish my snag list :P

I was just looking through the log files, and noticed the site/assets/sessions folder - it has almost 3,000 session files in it already and the site's not been online 24 hours yet!

Are these required for something? They all seem to contain the same content:

Session|a:0:{}

Seems a bit pointless, and I'm not sure what they relate to - any ideas anyone?

#2 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,526 posts
  • 854

  • LocationVihti, Finland

Posted 02 April 2012 - 02:01 PM

Pete: similar to this http://processwire.c...__fromsearch__1

We don't have this problem anymore and I don't remember actual solution, but maybe vsulin will drop in and tell? It was something about server settings and ubuntu defaults anyway...

#3 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 03 April 2012 - 05:12 AM

Cheers for that - it only appears to be keeping about 24 hours of them which is how it's suposed to work I see. Fortunately that stops it at 5,600 files ;)

#4 ryan

ryan

    Hero Member

  • Administrators
  • 5,773 posts
  • 3120

  • LocationAtlanta, GA

Posted 09 April 2012 - 10:08 AM

I'm going to be adding an option to store sessions in the DB soon too, so this will be another alternative option for those that want it.

#5 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 09 April 2012 - 10:18 AM

That's good to know ryan, even though I'm not sure if it's doing any harm with that many files. I was just curious as to why it needed so many empty files. Is it more of a "just in case" thing in case any session vars get set or something?

#6 ryan

ryan

    Hero Member

  • Administrators
  • 5,773 posts
  • 3120

  • LocationAtlanta, GA

Posted 09 April 2012 - 04:10 PM

This is one of those things that has to do with the inner-workings of PHP's session system. I've not attempted to override PHP's session storage mechanisms with PW (other than where it places the files) so this is probably a question for Rasmus Lerdorf. :) But I believe they are just placeholder files to track an active session, and they won't contain any significant data in them unless you specifically set it to the $session var. In lieu of tracking data, the filename itself is likely of more importance since it relates the session ID from the user's cookie to the session ID on the server. Of course, once we provide the option of DB session storage, we will be taking over more control from PHP in this area... at least when DB session storage is selected.

#7 netcarver

netcarver

    Sr. Member

  • Members
  • PipPipPipPip
  • 428 posts
  • 341

  • LocationUK

Posted 09 April 2012 - 04:18 PM

Ryan,

check out flourish's handling of sessions for some inspiration too. Though not fully documented at the front-of-site, it allows different session storage mechanisms via the setBackend() static call. I have to add, I haven't used this personally but thought I'd throw this into the ring if you are about to do some research.
Steve ☧

#8 joe_g

joe_g

    Jr. Member

  • Members
  • PipPip
  • 40 posts
  • 4

Posted 15 March 2013 - 05:06 AM

Hello there. I'm currently deleteing 160.000 session files : )

 

rgds,

J



#9 Soma

Soma

    Hero Member

  • Moderators
  • 3,194 posts
  • 1748

  • LocationSH, Switzerland

Posted 15 March 2013 - 07:37 AM

If the garbage collector on server is set wrong this can happen.

 

The good news, there's is now DB session module in PW since some versions in dev already to handle session via DB. Just install it. https://github.com/r...modules/Session


@somartist | modules created | support me, flattr my work flattr.com


#10 ryan

ryan

    Hero Member

  • Administrators
  • 5,773 posts
  • 3120

  • LocationAtlanta, GA

Posted 16 March 2013 - 05:46 AM

If PHP's garbage collector isn't working right, it'll affect DB sessions too. @joe_g, unless your site really handles that many sessions in a day, you may want to look into your PHP garbage collector settings. The relevant PHP settings are session.gc_probability, session.gc_divisor and session.gc_maxlifetime. We set the gc_maxlifetime automatically based on your $config->sessionExpireSeconds setting, but not the other two. However, you can force specific settings for those by adding lines like this to your /site/config.php file:

 

ini_set("session.gc_probability", 1);
ini_set("session.gc_divisor", 100);


#11 joe_g

joe_g

    Jr. Member

  • Members
  • PipPip
  • 40 posts
  • 4

Posted 20 March 2013 - 06:16 AM

thanks! Will try this.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users