Good day!
Faced with the fact that browsers - Safari, Firefox, YandexBrowser, do not store cookies for a very long time. What is it connected with? Chrome, for example, clearly stores, for a long time as indicated in the code. All the others are different, some people lose the cook in half an hour someone else in a day.
Here is the code for how I do it:
header("Content-Type: text/html; charset=UTF-8"); session_set_cookie_params('3600'); ini_set ("session.use_trans_sid", true); session_start(); ini_set ("display_errors", true); date_default_timezone_set('Europe/Moscow'); .... ....
I save cookies:
setcookie ("param1", $value1, time() + (3600*24*365), "/", "scroll"); setcookie ("param2", $value2, time() + (3600*24*365), "/", "scroll"); It seems to be doing everything right.
Thank you very much!
Ps.
Now everything is on the turn, saved in firefox, safari, but completely refuses to save cookies in chrome and Yandex Browser
Here is an example of what I am doing (I tried different versions)
header("Content-Type: text/html; charset=UTF-8"); session_set_cookie_params(3600); ini_set ("session.use_trans_sid", '1'); my_session_start(); ini_set ("display_errors", '1'); date_default_timezone_set('Europe/Moscow'); function my_session_start() { if (ini_get('session.use_cookies') && isset($_COOKIE['PHPSESSID'])) { $sessid = $_COOKIE['PHPSESSID']; } elseif (!ini_get('session.use_only_cookies') && isset($_GET['PHPSESSID'])) { $sessid = $_GET['PHPSESSID']; } else { session_start(); return false; } if (!preg_match('/^[a-z0-9]{32}$/', $sessid)) { return false; } session_start(); return true; } Then I save the cookies as follows:
$path = "/"; $domen = "localhost"; setcookie ("login", $row['email'], time() + (3600*24*365), $path, $domen); They simply do not appear in the list of cookies. But the session norms, is saved.
Then I tried to remove $ path and $ domen, started saving cookies. But for example, the session does not save in safar, Yandex browser and firefox, but in chrome it also saves the session and stores cookies. :(