Page 1 of 2

does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 1:25 pm
by kiwijones
hullo ... novice here.

does restarting apache reset php sessions?

thanks!

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 1:33 pm
by jayshields
Yes. Why didn't you just try it? Or search Google?

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 1:36 pm
by VladSun
No

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 1:39 pm
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.

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 1:40 pm
by kiwijones
ok ... there's 1 'no' and 1 'yes' ... maybe i should take a poll? :)

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 1:44 pm
by VladSun
Apache is an HTTP server. PHP manages user sessions. ;) And one could install Apache without installing PHP

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 1:46 pm
by kiwijones
that makes sense.

thanks vlad!

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 1:47 pm
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
 

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 1:53 pm
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)?

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 2:36 pm
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.

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 3:50 pm
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
 

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 4:13 pm
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?

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 4:17 pm
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.

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 4:20 pm
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

Re: does restarting apache reset php sessions?

Posted: Thu Feb 26, 2009 4:24 pm
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 :)