does restarting apache reset php sessions?

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

kiwijones
Forum Newbie
Posts: 7
Joined: Thu Feb 26, 2009 1:23 pm

does restarting apache reset php sessions?

Post by kiwijones »

hullo ... novice here.

does restarting apache reset php sessions?

thanks!
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: does restarting apache reset php sessions?

Post by jayshields »

Yes. Why didn't you just try it? Or search Google?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: does restarting apache reset php sessions?

Post by VladSun »

No
There are 10 types of people in this world, those who understand binary and those who don't
kiwijones
Forum Newbie
Posts: 7
Joined: Thu Feb 26, 2009 1:23 pm

Re: does restarting apache reset php sessions?

Post by kiwijones »

thanks for the reply jay.

i tried it and i searched google too. but my results contradicted the expected results, hence i had to resort to an expert opinion (= you guys) :)

when i do a

Code: Select all

$ /opt/apache/bin/httpd -k restart
apache is restarted but for some strange reason, the php sessions are preserved.
Last edited by kiwijones on Thu Feb 26, 2009 1:41 pm, edited 1 time in total.
kiwijones
Forum Newbie
Posts: 7
Joined: Thu Feb 26, 2009 1:23 pm

Re: does restarting apache reset php sessions?

Post by kiwijones »

ok ... there's 1 'no' and 1 'yes' ... maybe i should take a poll? :)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: does restarting apache reset php sessions?

Post by VladSun »

Apache is an HTTP server. PHP manages user sessions. ;) And one could install Apache without installing PHP
There are 10 types of people in this world, those who understand binary and those who don't
kiwijones
Forum Newbie
Posts: 7
Joined: Thu Feb 26, 2009 1:23 pm

Re: does restarting apache reset php sessions?

Post by kiwijones »

that makes sense.

thanks vlad!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: does restarting apache reset php sessions?

Post by VladSun »

Code: Select all

cat /etc/cron.d/php4
# /etc/cron.d/php4: crontab fragment for php4
#  This purges session files older than X, where X is defined in seconds
#  as the largest value of session.gc_maxlifetime from all your php.ini
#  files, or 24 minutes if not defined.  See /usr/lib/php4/maxlifetime
 
# Look for and purge old sessions every 30 minutes
09,39 *     * * *     root   [ -d /var/lib/php4 ] && find /var/lib/php4/ -type f -cmin +$(/usr/lib/php4/maxlifetime) -print0 | xargs -r -0 rm
 
There are 10 types of people in this world, those who understand binary and those who don't
kiwijones
Forum Newbie
Posts: 7
Joined: Thu Feb 26, 2009 1:23 pm

Re: does restarting apache reset php sessions?

Post by kiwijones »

thanks for that info too vlad!

on a related note (this is more of a linux scheduling question), can you see *all* crontabs that a system is running (i mean not just for a particular user ... but all users and all processes)?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: does restarting apache reset php sessions?

Post by VladSun »

You can't see the crond processes running because, crond forks a new process for every task only when it's needed - i.e. it's time to run it.
You can take a look of crond config files to determine what processes are to be run.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: does restarting apache reset php sessions?

Post by Weirdan »

VladSun wrote:You can take a look of crond config files to determine what processes are to be run.

Code: Select all

 
sudo ls  /var/spool/cron/crontabs/| while read name; do echo '# User:' $name; sudo cat /var/spool/cron/crontabs/$name; done
 
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: does restarting apache reset php sessions?

Post by jayshields »

I stand corrected.

Care to explain
Apache is an HTTP server. PHP manages user sessions. ;) And one could install Apache without installing PHP
in more detail Vlad?

I thought with PHP being a module inside Apache, restarting Apache would restart PHP, and reset the sessions. I'd of sworn that I've restarted Apache in the past to wipe sessions, but a test just now proves not. Where are the physical session files stored in a typical Apache/PHP install?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: does restarting apache reset php sessions?

Post by John Cartwright »

jayshields wrote:Where are the physical session files stored in a typical Apache/PHP install?
Take a look at your session_save_path php.ini variable.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: does restarting apache reset php sessions?

Post by VladSun »

Weirdan wrote:
VladSun wrote:You can take a look of crond config files to determine what processes are to be run.

Code: Select all

 
sudo ls  /var/spool/cron/crontabs/| while read name; do echo '# User:' $name; sudo cat /var/spool/cron/crontabs/$name; done
 
cron searches its spool area (/var/spool/cron/crontabs) for crontab
files (which are named after accounts in /etc/passwd)....

...cron also reads /etc/crontab, which is in a slightly different format
(see crontab(5)). Additionally, cron reads the files in /etc/cron.d:
it treats the files in /etc/cron.d as in the same way as the
/etc/crontab file
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: does restarting apache reset php sessions?

Post by VladSun »

jayshields wrote:I thought with PHP being a module inside Apache, restarting Apache would restart PHP, and reset the sessions.
It's file storage (usually), so why to delete them on init? Deletion of this files is done by crond jobs - simple and easy to do :)
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply