<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>session_close Archives - CNERIS</title>
	<atom:link href="https://cneris.com/en/tag/session_close/feed/" rel="self" type="application/rss+xml" />
	<link>https://cneris.com/en/tag/session_close/</link>
	<description></description>
	<lastBuildDate>Tue, 29 Oct 2024 09:09:24 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
	<item>
		<title>A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.</title>
		<link>https://cneris.com/en/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-2/</link>
					<comments>https://cneris.com/en/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-2/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 29 Oct 2024 09:09:24 +0000</pubDate>
				<category><![CDATA[Centos]]></category>
		<category><![CDATA[Dedicated servers]]></category>
		<category><![CDATA[Plesk]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[System Administration]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[session_close]]></category>
		<category><![CDATA[session_start]]></category>
		<category><![CDATA[wordpress]]></category>
		<guid isPermaLink="false">https://cneris.com/?p=2680</guid>

					<description><![CDATA[<p>This error occurs because the session_start() function is creating a PHP session, which interferes with REST API and loopback requests in WordPress. To resolve this: Locate the session_start() code Search your theme or active plugins for the session_start() function. It may be in the theme’s functions.php file or in a custom plugin. Add session_write_close() after [...]</p>
<p>The post <a href="https://cneris.com/en/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-2/">A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This error occurs because the <code>session_start()</code> function is creating a PHP session, which interferes with REST API and loopback requests in WordPress. To resolve this:</p>
<ol>
<li><strong>Locate the <code>session_start()</code> code</strong><br />
Search your theme or active plugins for the <code>session_start()</code> function. It may be in the theme’s <code>functions.php</code> file or in a custom plugin.</li>
<li><strong>Add <code>session_write_close()</code> after <code>session_start()</code></strong><br />
Ensure <code>session_write_close()</code> is called after each <code>session_start()</code> call, before making any HTTP requests. This will close the session and allow the REST API to work correctly. For example:</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="sticky top-9 md:top-[5.75rem]"></div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><span class="hljs-title function_ invoke__">session_start</span>();<br />
<span class="hljs-comment">// Your code here</span><br />
<span class="hljs-title function_ invoke__">session_write_close</span>();<br />
</code></div>
</div>
</li>
<li><strong>Use the <code>init</code> hook in WordPress</strong><br />
If <code>session_start()</code> needs to be in <code>functions.php</code>, make sure to wrap it in the <code>init</code> hook and use <code>session_write_close()</code> like this:</p>
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950">
<div class="sticky top-9 md:top-[5.75rem]"></div>
<div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-php"><span class="hljs-title function_ invoke__">add_action</span>(<span class="hljs-string">'init'</span>, function() {<br />
    <span class="hljs-keyword">if</span> (!<span class="hljs-title function_ invoke__">session_id</span>()) {<br />
        <span class="hljs-title function_ invoke__">session_start</span>();<br />
        <span class="hljs-title function_ invoke__">session_write_close</span>();<br />
    }<br />
});</code></div>
</div>
</li>
</ol>
<p>The post <a href="https://cneris.com/en/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-2/">A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.</a> appeared first on <a href="https://cneris.com/en">CNERIS</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://cneris.com/en/a-php-session-was-created-by-a-session_start-function-call-this-interferes-with-rest-api-and-loopback-requests-the-session-should-be-closed-by-session_write_close-before-making-any-http-requests-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
