I need to set the php_value session.save_path in .htaccess. This seems to require a full path, a relative path doesn't seem to work.
My webapplication runs on both Windows and Linux servers and I'd like to keep the .htaccess file the same on both systems, for deployment reasons.
Is it possible to reference the directory where .htaccess is, in the .htaccess file itself, something like this :
php_value session.save_path "<%systempath>/sessions"
with <%systempath> being automatically filled in on each system ?
You can automatically prepend a php file which will configure php with ini_set()
# .htaccess
php_value auto_prepend_file "autoprepend.php"
Then:
// autoprepend.php
ini_set('session.save_path', __DIR__ . '/sessions');
This way it will work for any php script within the directory.
I don’t think this is possible with any Apache directive.
But you can do that with PHP:
ini_set('session.save_path', dirname(__FILE__).'/sessions');
Here __FILE__
is the magic constant that holds the file system path to the current PHP script file and dirname
returns the parent directory of that file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With