BACKGROUND
I have a folder on my site /folder and I wanted to have a session created in this folder only available inside /folder. To achieve this, I did the following:
I created a folder for my session outside the public_html directory called "sessionfolder"
I created a php.ini file inside the /folder with the content below:
session.gc_maxlifetime = 864000
session.save_path = '/home/website/sessionfolder'Before creating the SESSIONS, I call this PHP snippet below:
session_set_cookie_params(864000, '/folder', '.website.com', 0, 1);
ini_set('session.use_only_cookies', 1);
ini_set('session.gc_maxlifetime', 864000);
Everything worked well at this point, my SESSIONS were created and only available in /folder.
THE PROBLEM
Now, I want the SESSION created in /folder to be available in /folder2 and /folder3.
To fix this, I changed session_set_cookie_params(864000, '/folder', '.website.com', 0, 1);
to session_set_cookie_params(864000, '/', '.website.com', 0, 1);
and deleted the SESSIONS in /home/website/sessionfolder.
This worked on my PC, maybe because I cleared my cookies and sessions or for whatever reason; but then I started receiving calls that they cannot login anymore. They are simply redirected back to login page with no error message which is obviously a SESSION issue.
My Question
How do I update my solution to ensure it works for new and old users while achieving the objective (SESSION created in /folder being available in /folder2).
Thank you!
0 comments:
Post a Comment