I am trying to get session id using session_id(); But I get to know that It will be regenerated after every 5 minutes.
So i got a trick to set random number into a user defined session variable . like ,
$uniqueId = uniqid(rand(), TRUE);
$this->session->set_userdata("my_session_id", md5($uniqueId));
Now question is where should I place this code. If I place this code in my controller's constructor , It will be executed on each request. and will give me a different session id for each request.
How can I set this session variable only once ? and it will not change until session destroy() .
use php's built in function:
$session_id = session_id();
now $session_id
is a unique session id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With