Answer the question
In order to leave comments, you need to log in
How to pass session variables between independent scripts?
Hello newbie web developer. There was a problem I can not give the mind. It's in the first file:
// Сессия живет 24 часа
ini_set('session.gc_maxlifetime', 86400);
// Свой идентификатор сессии, нет куки
session_id('test');
// Заново или возобнавляем
session_start();
// Цена на рынке меняется динамически
for ($i = 0; $i < 100; $i++) {
$_SESSION['price'] = $i;
sleep(1);
}
// Свой идентификатор сессии, нет куки
session_id('test');
// Заново или возобнавляем
session_start();
for ($i = 0; $i < 100; $i++) {
echo $_SESSION['price'];
sleep(1);
}
Answer the question
In order to leave comments, you need to log in
Good day.
It seems to be puffing the session file either until the script ends, or until session_write_close () is called; And then when you try to simultaneously record xs that will be recorded.
https://secure.php.net/manual/ru/function.session-...
To exchange data between scripts, you can try https://php.net/manual/en/ref.shmop.php
or sockets https://habr.com/ru/post/209864/ or a memcache https://habr.com/ru/post/108274/ or a file on disk and serialization/deserialization from JSON.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question