CodeIgniter Forums
Codeigniter 4 - Sessions and VIBER API - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Codeigniter 4 - Sessions and VIBER API (/showthread.php?tid=78998)



Codeigniter 4 - Sessions and VIBER API - N04H - 04-06-2021

Hello, everyone!

I am developing a Viber chat-bot and stucked with such kind of problem:

After every request from Viber server to my, Codeigniter creates new session, and all of the data, that I've stored during previous requests is destroyed.
I have the main method in my front-controller (Viber::index), which recieves the request from VIBER API. I've putted simple print_r to write session data after each request to file on the server.
Code:
public function index()
{
    $request = $this->request->getJSON();

    $file = APPPATH . 'debug.txt';
    $current = file_get_contents($file);
    $current .= print_r($this->session->get(),true);
    file_put_contents($file, $current);   
}
And, after several requests from Viber to my front-controller I have next picture in my debug.txt file:
Code:
Array
(
    [__ci_last_regenerate] => 1617702828
)

Array
(
    [__ci_last_regenerate] => 1617702828
)

Array
(
    [__ci_last_regenerate] => 1617702830
)
Is it possible somehow to save the state of the session, and use it throught all of the application?
I'll be very grateful for any help...