my objective: I set two cookies over two different pathes containing session Ids
These two pathes are not common so cookies are not shared
/baharshop/admin/
/baharshop/public/
in requests from /baharshop/admin/
only one session is created but in requests from /baharshop/public/
sessions keep creating and can't get a hold to previous session
and also if I write session_start in /baharshop/public/
and only run requests from /baharshop/admin/
again new sessions are created for /baharshop/public/
without even runnig any requests from /baharshop/public/
now my project directory design is like this
- /baharshop/ -- root director
- /baharshop/admin/
- /baharshop/public/
upon loading any requests from /baharshop/admin/
I first include file config_admin.php
to start one session only
config_admin.php
session_set_cookie_params((7 * (24*3600)), "/baharshop/admin/");
session_start();
then offcourse include the file in all /baharshop/admin/
applications
<?php require_once "../config/config_admin.php";?>
<?php
echo "<pre>";
print_r($_COOKIE);
echo "</pre>";
}
?>
and it works just fine
problem is upon only adding these lines in config_public.php
config_public.php
session_set_cookie_params( ((6*31) * (24*3600)), "/baharshop/public/");
session_start();
then for every request from "/baharshop/public/"
new sessions keep creating again and again
<?php require_once "../config/config_public.php";?>
<?php
function get_content(): void{
echo "<pre>";
print_r($_COOKIE);
echo "</pre>";
}