Re: [RFC][VOTE] Add session_create_id() function
| From: | Leigh | Date: | Thu, 11 Aug 2016 18:25:22 +0000 |
| Subject: | Re: [RFC][VOTE] Add session_create_id() function | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-95045@lists.php.net to get a copy of this message | ||
On Wed, 10 Aug 2016 at 10:15 Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> Hi all,
>
> This is RFC for adding session_create_id() function.
>
> Session ID string uses special binary to string conversion. Users
> should write lengthy and slow code to have the same session ID string
> as session module does.
I disagree, this pretty much covers it:
function session_create_id()
{
$encoded = base64_encode(random_bytes(32));
// Use same charset as PHP
return rtrim(strtr($encoded, '+/', ',-'), '=');
}