[UPHPU] sessions in front controller

jtaber jtaber at johntaber.net
Tue Oct 10 12:55:13 MDT 2006


Alvaro Carrasco wrote:
> jtaber wrote:
>> having mental blockage on this one:
>> a front controller has a session_start() to initialize the session 
>> but each time a page is called the session_start()  gets called again 
>> which seems to wipe out the session vars - tried to wrap the 
>> session_start() ie
>>
>> if (!isset($_SESSION['start'])) {
>> session_start();
>> $_SESSION['start']=1;
>> }
>> .... test for right session
>> .....
>>
>> is this right ?  does anyone have an example of using session in a 
>> front controller (sorry google search wasn't showing me any good 
>> examples).  thks
>>
>>
>>
> session_start() does not clear the session vars, and it is actually 
> required on every single page that uses the session.
that's actually what I thought and have used on other pages - I've gone 
back and put session_start() on all views and controller functions - I 
think the problem might indeed be in the php.ini

the result I'm getting is when checking on the next page in sequence, I 
am getting a new session id and blanks for the session vars I've set on 
the first page

in the php.ini I've noticed the following defaults:
session.save_handler = files
;session.save_path = /var/lib/php5
; session.use_only_cookies = 0
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =

now - I uncommented out session_save_path and session_use_only cookies 
(idea being to run with cookies off  putting session in url)  - I can't 
remember if the other settings need to be changed.

meanwhile, could the use of:
header('Location:/testapp/welcome/');  be causing a problem - shouldn't 
the session be attached to the end of that ?

thks for any help



More information about the UPHPU mailing list