The way to create a custom session id without editing php.ini

I am trying to create my own session id generator. From what I read on sites, you can do this by manually editing the PHP settings files, however it will not be available until I switch from my shared servers to fully customizable.

I am trying to ask if it is possible to indicate how session identifiers are generated by entering PHP code on the page? My intention is to use the same mechanics as the default identifier generator, but use sha512 and some useful properties like salt.

+6
source share
1 answer

If you pass a string to the session_id() function before calling session_start() , you can set the session identifier yourself. For instance:

 function generate_id() { ... return $your_id; } session_id(generate_id()); session_start(); 
+8
source

Source: https://habr.com/ru/post/899392/


All Articles