FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


sessions help





imagefree
I have developed a script that starts a session whenever a user (whether logged in or not) comes to the site, so if 100,000 unique people come to site, 100,000 sessions are generated.

I am using a session based redirection system so that when every time a page loads, a new session variable is created (inside session array) without deleting or unsetting the previous one. That new variable contains the URL of current page.

This redirection system is perfect in solving my needs, but now I am curious about side effects.

The script is excessively (but not unnecessarily) creating session variables on each page, so that one unique visiter after 100 page visits has 100+ session variables in his session.

The problem is that mostly users leave the site without any clue and without logging off (if logged in). This keeps the sessions and sessions variable untouched and a lot of precious disk space may be left occupied when heavy strings (like URLs) are saved in sessions.

I want to delete these sessions periodically (say after exactly 10 days of creating session), so that only latest sessions are left on the disk. Can you please tell me how to do this?
Can someone provide me possible solution like modifying php settings, or using CRONJOBS (script).
Or give me an alternative suggestions?
sonam
How I know you don't need to do anything. First of all you are not create all time new session. Session_start just start session handling but not create new one. This is always one session per user. If you create some session arrays or variables this is exist as long you are not change it, but all of your sessions are part of one main session. Something like DB where you insert in one table with different columns and rows some datas. And on the end, ones when user close his/her browser then session is over and it is automatically destroyed after three minutes. Next time, when user come to your site session grab cookie informations (if you are define it) and handle it.

Actually I like very much sessions because I can fill it with any type of data and use on any page on site without posting or geting trought some form or url.

Sonam
imagefree
sonam wrote:
How I know you don't need to do anything. First of all you are not create all time new session. Session_start just start session handling but not create new one. This is always one session per user. If you create some session arrays or variables this is exist as long you are not change it, but all of your sessions are part of one main session. Something like DB where you insert in one table with different columns and rows some datas. And on the end, ones when user close his/her browser then session is over and it is automatically destroyed after three minutes. Next time, when user come to your site session grab cookie informations (if you are define it) and handle it.

Actually I like very much sessions because I can fill it with any type of data and use on any page on site without posting or geting trought some form or url.

Sonam


OK how do PHP know that the browser is closed? What if the connection is already failed?
rvec
it doesn't know, it just assumes that after there hasn't been any activity for a while.
imagefree
rvec wrote:
it doesn't know, it just assumes that after there hasn't been any activity for a while.


so do it mean if a visiter takes more than 3 minutes to read a page or take more time, the session ends( even without closin browser)? It never happened to me. Also that SESSION cookie is set for lifetime of current session (ie current browser session), and continues to work untill the browser is closed.

Can you please refer me to any good article about this problem?
sonam
Quote:
so do it mean if a visiter takes more than 3 minutes to read a page or take more time, the session ends( even without closin browser)?


NO! They will have their session as long as browser are open. I don't know about inacitivity (if is browser open but not active), I think this is regulated with session.gc_maxlifetime http://www.captain.at/howto-php-sessions.php
Here is all about session on php.net
http://www.php.net/manual/en/session.configuration.php

Sonam
rvec
there is no way the server knows the browser is still open. A browser doesn't keep pinging the server or something. The browser sends a request, gets one and they're done. The sessions are server-based so the browser can't store those, and the server has to throw them away after a while. So my guess is, that if you login to frihost, and keep your browser open for a night you'll be logged out in the end.
Related topics
can i help?
help,Bonding
php sessions
PHP: Sessions and Cookies
HELP ME BONDINGS!!!!
FireFox and Cookies/Sessions
Free Live HElp software
Need help with Members area/link adder
Help me Out with this Unwrittable Form
$_COOKIE and $_SESSION help needed!
Need Help : Dreamweaver sessions
Help with Dreamweaver sessions !!!!!!!!
Phpbb Sessions - Need help getting guests/members.....
Joomla (Sessions Unwritable)
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.