cakephp - How to know webroot in core.php -
i'm using cakephp 2.3.1.
our server has independent applications in 1 server. want change session.cookie_path
setting following cookbook :
configure::write('session', array( 'defaults' => 'php', 'ini' => array( 'session.cookie_path' => '/app/dir' ) ));
i change this. here problem. need set session.cookie_path
value webroot
dynamically (without string literal value such '/app/dir'
).
i've tried use $this->webroot
following this q&a, of course not work because there no controller in file app/config/core.php
.
any ideas?
i realized php variable available : $_server['request_uri']
. solve problem.
$requesturi = $_server['request_uri']; $webroot = preg_replace('/(^\/[^\/]+\/).*$/', '$1', $requesturi); //echo $webroot; configure::write('session', array( 'defaults' => 'cake', 'ini' => array( 'session.cookie_path' => $webroot // looks '/app/' ) ));
but solution not have reusability enough : not work apps located in deeper directories such /apps/app1/
.
i'm still awaiting better solution.
Comments
Post a Comment