Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Define GRAV_ROOT constant outside Grav Core

Started by xavi 8 years ago · 0 replies · 670 views
8 years ago

Hello,

I would like to know is if there is any possibility of being able to define GRAV_ROOT constant before the declaration of it ( /system/defines.php :: 20 )
if (!defined('GRAV_ROOT')) {
define('GRAV_ROOT', str_replace(DIRECTORY_SEPARATOR, DS, getcwd()));
}

The problem is that I am working with sessions and I have noticed that grav uses current working directory to create the name of the session ( /system/src/Grav/Common/Service/SessionServiceProvider.php :: 71 )
$session_name = $inflector->hyphenize($config->get('system.session.name', 'grav_site')) . '-' . substr(md5(**getcwd()**), 0, 7);

When I deploy the new code (with ansible), current directory of the project changes from
/var/www/project/releases/20183010120000Z/
to
/var/www/project/releases/20183010130000Z/

Ansible automatically creates a symlink from
/var/ww/project/current/
to the latest release when a deploy is made (all deployment software work like this)

due to the root path changes, session name also changes (it depends on getcwd()), therefore user session is lost (old session name is not used anymore).

If GRAV_ROOT can't be predefined, would it be possible to create a feature on your side for not using getcwd() in the session name?

Regards,
xavi

Suggested topics

Topic Participants Replies Views Activity
General · by jeremycherfas, 1 week ago
5 196 5 hours ago
General · by lynbor, 6 days ago
2 130 3 days ago
General · by Old Man Umby, 1 week ago
1 103 1 week ago
General · by Sebastian, 2 weeks ago
1 128 2 weeks ago
General · by Andy Miller, 3 weeks ago
0 251 3 weeks ago