Doc #79609 [Fbk]: Warning in session_create_id Example #1

From: Date: Mon, 18 May 2020 21:14:58 +0000
Subject: Doc #79609 [Fbk]: Warning in session_create_id Example #1
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17601@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79609&edit=1 ID: 79609 Updated by: requinix@php.net Reported by: software_onbekend at hotmail dot com Summary: Warning in session_create_id Example #1 Status: Feedback Type: Documentation Problem Package: Session related PHP Version: Irrelevant Block user comment: N Private report: N New Comment: The only way I see session_create_id failing is either (a) you don't have good enough crypto, or (b) you're using a custom session handler that's not behaving well. So what are you session settings? Previous Comments: ------------------------------------------------------------------------ [2020-05-18 19:03:35] software_onbekend at hotmail dot com Exact warning: from def. environment: Warning: session_create_id(): Failed to create new ID in E:\xampp\htdocs\8\index.php on line 20 ------------------------------------------------------------------------ [2020-05-18 18:17:05] requinix@php.net > Here I get the warnings. Exactly what are they? > The explanation of the return values doesn't explain the link between these values 0, 1 > & 2. Use the constants. If you want something you can read, use the constants to output human friendly strings like "active". ------------------------------------------------------------------------ [2020-05-18 17:21:31] software_onbekend at hotmail dot com The def. environment is PHP 7.4.3 (xamp installation on Windows). session.auto_start = "Off". "display_errors" and "display_startup_errors" values are "On". Here I get the warnings. Tested example in prod. environment with PHP 7.3.17. session.auto_start = "Off" No warning because the most hosted platform has the "display_errors" and "display_startup_errors" at "Off" so the warnings and errors are suppressed. No output to webbrowser. About the session-status. echo session_status; gives int. as answer in the browser (values 0 or 1 or 2) The explanation of the return values doesn't explain the link between these values 0, 1 & 2. The contributed note from "sasi dot viragelet at gmail dot co" gives the answer. Perhaps we can use that info to improve the documentation. Just my 2 cents. Have a nice day. ------------------------------------------------------------------------ [2020-05-17 21:59:23] a at b dot c dot de For the first question: The sample code is working fine for me. What version are you using? Do you perhaps have session.auto_start enabled? For the second question: PHP_SESSION_ACTIVE is an integer. ------------------------------------------------------------------------ [2020-05-17 21:59:22] requinix@php.net Are you sure you're looking at https://www.php.net/manual/en/function.session-create-id.php? Because, > Warning: session_create_id(): Failed to create new ID in index.php on line 20. > Generating new session id is not allowed when the session is already started. The example is working for me. > Also at line 16, the if statement need an integer because the output of session_status is an > integer. It does that already. > Can the documentation for the "session-status" also be updated with the integer > return values? It does that too. > The example also uses "session_commit()", this is an alias of > "session_write_close", wouldn't it be > better to use "session_write_close" instead of "session_commit" ? The alias is not deprecated, but it probably would be better, yes. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=79609 -- Edit this bug report at https://bugs.php.net/bug.php?id=79609&edit=1

« previous php.doc.bugs (#17601) next »