Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100083 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74187 invoked from network); 28 Jul 2017 14:11:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jul 2017 14:11:29 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-wm0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:38627] helo=mail-wm0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/A5-40376-F064B795 for ; Fri, 28 Jul 2017 10:11:28 -0400 Received: by mail-wm0-f42.google.com with SMTP id m85so118537961wma.1 for ; Fri, 28 Jul 2017 07:11:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:from:message-id; bh=7oIP/98m533OZwsWXXeMwVxiJArB7CBWDRhB2JKxWGc=; b=iiEeeCRuYCRX2/eZ2pCJWlBXMlZRaWxplUmGAYX6M6quqn4OP0FiV8biNB1H4zq9hD Z3Rq31g/BnjcFyR02P2oI49gtMWb1571SUXlJK0vIi0bRhSH3DBh4hMQ2YOVjIehuLTt Oy4hG3xCuVTCPx+hZ1zB0SfrHpbiaRm2pcib8+4DyGit25ZooTt7eh+qUg/W94NFDoq7 SqNlLJxGNlc8d3ceC1LG6PzRqs7HQUUv8NGk2pQpwvQn8jrwV7z5Upv/3Nrr3+AW9nNj pKm7QXez7TpGJqGz4XmPyD2uup6oH5jDZEn/hdEYU8r8oC9wBePdvyo+M7TM4GSICAay y3/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=7oIP/98m533OZwsWXXeMwVxiJArB7CBWDRhB2JKxWGc=; b=clSLeejGjbGeOBAkb70phZdyWQPlPp9Xe/bJ6zjbItFXhJA6D5jSPEsqSBxs/pJ1y0 UJaRIIGkhDsWUoTqc8ImDBVPAfk1dzoePBgxBlP3foqMWlvIte1lENdYeBnC7u5omU+1 jUM8opCxvG1MGaYMXNvQNcTXJKJNp2ntM0u6QftHSxU+c0HooBP2J1FI33ji4+UhGGJD sQ99KKntFRhexiCbjLfTBGNy88HZgkFn+5nERbyDwluenfyob+Wxdrunm3WNlMgdiww+ PAmHaBpbNrmT1xLi1Ski/75IsZbyBMXXNa+dTmMfVwHgoxz81rKFv3KJq2TFkWRo7FTx h69g== X-Gm-Message-State: AIVw110+TtwXYbiXFCN8oWlT3RnVT9DB6OlcFfkPGlm2EzFeFvXIDnOx Vb5JrFuijoqPcE6RSf0= X-Received: by 10.28.51.5 with SMTP id z5mr5525668wmz.80.1501251083969; Fri, 28 Jul 2017 07:11:23 -0700 (PDT) Received: from [10.177.87.236] (92.40.249.44.threembb.co.uk. [92.40.249.44]) by smtp.gmail.com with ESMTPSA id s133sm7954273wmb.4.2017.07.28.07.11.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Jul 2017 07:11:23 -0700 (PDT) Date: Fri, 28 Jul 2017 15:11:16 +0100 User-Agent: K-9 Mail for Android In-Reply-To: References: <28093140-0D0D-4157-AAA3-E8F1A570E67A@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net,"lists@rhsoft.net" Message-ID: <422D7E05-864E-40EB-AEEB-81DFED80CA72@gmail.com> Subject: Re: [PHP-DEV] session_start() should not reset $_SESSIOn if it's not empty From: rowan.collins@gmail.com (Rowan Collins) On 28 July 2017 14:37:10 BST, "lists@rhsoft=2Enet" wro= te: >(Arguably, all the other superglobals should be read only for the same >reason, but that would be a huge break now=2E) > >make them readonly would break my whole codebase=20 Yes, I only meant that as an absolutely hypothetical "if I had a time mach= ine and could design it a different way=2E=2E=2E", I realise it would break= everything to change it now=2E >> If I understand you right, the scenario you describe is "I don't want >to start a session yet, but if and when I do, I want to put this data >into it"=2E It feels like that could be adequately handled in userland >with a wrapper object (or global var and functions if you prefer), >which reads to and from $_SESSION when a session is open, but a a >holding array when it's not yet=2E > >that don't work because at this point you don't know in userland if you >started a completly new session which should be initialized with values >for follow-up requests or use the existing values from a previous=20 >request - at least not without writing ugly code Do you mean like this? session_start(); if ( ! $_SESSION['initialised'] ) { $_SESSION['initialised'] =3D true; foreach ( $this->session_init_vars as $var =3D> $val ) { $_SESSION[ $var ] =3D $val; } } That should work as long as you don't run session_start() outside that fun= ction, and centralising that is already necessary to avoid "already started= " errors=2E Regards, --=20 Rowan Collins [IMSoP]