I use script on my website like this localhost/panel/index.php
in index.php
the script set session like this
$cookie_lifetime = ini_get('session.cookie_lifetime') ? ini_get('session.cookie_lifetime') : 0;
session_set_cookie_params($cookie_lifetime , rtrim(dirname($_SERVER["SCRIPT_NAME"]),"/") . "/", $_SERVER['SERVER_NAME'], $ssl, true);
session_start();
I need to use this session on localhost/index.php
by using this session.
To set the session cookie path to a fixed location you don't need any calculation:
session_set_cookie_params($cookie_lifetime , '/index.php', $ssl, true);
It's worth noting that the default value is /
.