{"id":18066825,"date":"2024-10-11T08:57:32","date_gmt":"2024-10-11T08:57:32","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/session-errors-2\/"},"modified":"2024-10-11T08:57:32","modified_gmt":"2024-10-11T08:57:32","slug":"session-errors-2","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/session-errors-2\/","title":{"rendered":"session() errors"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi, your restore_boot() function is called on just every load action in frontend, backend, ajax-calls. the simple session_start() line throws thousands of &#8220;session_start() will be ignored &#8230;&#8221; error log entries, if i try to start a session too in my coding.<br \/><br \/>Could you please wrap your session_start just in an if-condition? <br \/><br \/>if(session_status() === PHP_SESSION_NONE) {<br \/>session_start(); \/\/ phpcs:ignore<br \/>}<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I do so on my session_start, but somehow your session_start is not recognized as an active session, when i do my call. so my own if condition does not work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And by the way. Why is the function executed all the time. Isn&#8217;t it just necessary, if i want to do a backwpup restore?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(Without checking by myself, if correct) ChatGPT suggests something like this for your session_start:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">if (is_admin() || (defined(&#8216;DOING_AJAX&#8217;) &amp;&amp; isset($_REQUEST[&#8216;action&#8217;]) &amp;&amp; $_REQUEST[&#8216;action&#8217;] === &#8216;restore&#8217;)) {<br \/>if (session_status() !== PHP_SESSION_ACTIVE) {<br \/>session_start(); \/\/ phpcs:ignore<br \/>}<br \/>}<\/p>\n","protected":false},"template":"","class_list":["post-18066825","topic","type-topic","status-publish","hentry","topic-tag-restore","topic-tag-session"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18066825","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18066825\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18066825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}