Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95138 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32249 invoked from network); 14 Aug 2016 12:34:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Aug 2016 12:34:48 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:57511] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/CD-36656-56560B75 for ; Sun, 14 Aug 2016 08:34:47 -0400 Received: (qmail 101960 invoked by uid 89); 14 Aug 2016 12:34:42 -0000 Received: from unknown (HELO mail-qt0-f181.google.com) (yohgaki@ohgaki.net@209.85.216.181) by 0 with ESMTPA; 14 Aug 2016 12:34:42 -0000 Received: by mail-qt0-f181.google.com with SMTP id u25so11914894qtb.1 for ; Sun, 14 Aug 2016 05:34:41 -0700 (PDT) X-Gm-Message-State: AEkoouta68EubkdsuhALpkhgv/k5luoJ1Bj0LkezZP5kxNnqHUkPqJoSTBpbZ/sduDklyAwHC9d2r68qQPpbHg== X-Received: by 10.200.45.181 with SMTP id p50mr25768303qta.31.1471178076118; Sun, 14 Aug 2016 05:34:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.85.242 with HTTP; Sun, 14 Aug 2016 05:33:55 -0700 (PDT) In-Reply-To: <592333a7-2c73-38a4-b400-f3f2c7bf2f72@lsces.co.uk> References: <592333a7-2c73-38a4-b400-f3f2c7bf2f72@lsces.co.uk> Date: Sun, 14 Aug 2016 21:33:55 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Lester Caine Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC][VOTE] Add session_create_id() function From: yohgaki@ohgaki.net (Yasuo Ohgaki) Hi Lester, On Sun, Aug 14, 2016 at 5:35 PM, Lester Caine wrote: > On 14/08/16 01:56, Yasuo Ohgaki wrote: >> IMO. PHP should be easiest, yet secure, Web application programming language. >> I don't see any benefits, but only drawbacks, forcing users "to know session >> management details to write secure code" while it is very easy to implement >> tham in Session module. > > Sessions are something I rely on, but have thrown numerous problems over > the years. In my systems they should exist for the duration of a client > being logged into the system and so any problems either end have to be > handled. For that reason I store them in the database so when a client > has to log in again we can clear their last activity and start a new > one. The clients can be carrying out interviews for an hour or more, so > previous 'improvements' that try to clear 'inactive sessions' often lost > MY sort of sessions. Clients are only allowed to log on once so I need > to pick up if they try and start a second session, but I don't believe I > NEED all the complexity of cryptography secure id's? Just ones where I > CAN actually identify the client ... or should I be handling that > separate from the actual session_id ? Concept of Session is simple just like transaction. Concept of transaction is simple but implementation requires complexity to do the job right. You wouldn't say 'Transaction could be inconsistent under rare unfortunate situations' probably. Anyway, session module generates collision free session ID by default. Why not for API generates new ID? Collision check for new session ID is cheap because it does not happen for every request, but only when session ID is regenerated. In addition, user needs a lot of work and details of session, including session save handler knowledge to generate collision free session ID. If anyone would really like to remove collision check overhead, they should do it by themselves. Unlike collision free session ID generation, it's very easy. Users can do ini_set('session.use_strict_mode', 0); session_id('my_session_id'); session_start(); with their own responsibility and risk. Regards, P.S. The next step having session_create_id() is session_regenerate_id() change. For example, having user ID prefixed session would be just session_regenerate_id(session_create_id($userid)); Warning: To do things like this safely, user MUST enable use_strict_mode!! -- Yasuo Ohgaki yohgaki@ohgaki.net