<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Question2Answer Q&amp;A - Recent questions tagged qa_cookie_get</title>
<link>https://www.question2answer.org/qa/tag/qa_cookie_get</link>
<description>Powered by Question2Answer</description>
<item>
<title>When to use qa_cookie_get() and qa_cookie_get_create() ?</title>
<link>https://www.question2answer.org/qa/20520/when-to-use-qa_cookie_get-and-qa_cookie_get_create</link>
<description>

&lt;p&gt;
	Both functions are defined in &lt;strong&gt;qa-app-cookies.php&lt;/strong&gt;.&lt;/p&gt;


&lt;p&gt;
	function qa_cookie_get() → &quot;Return the user identification cookie sent by the browser for this page request, or null if none&quot;&lt;/p&gt;


&lt;p&gt;
	function qa_cookie_get_create() → &quot;Return user identification cookie sent by browser if valid, or create a new one if not.&amp;nbsp; &amp;nbsp; Either way, extend for another year (this is used when an anonymous post is created)&quot;&lt;/p&gt;


&lt;p&gt;
	
&lt;br&gt;
	This question originated from finding a &lt;a href=&quot;http://www.question2answer.org/qa/20376/solution-for-bug-headers-already-sent-theme-base-php-cookies&quot; rel=&quot;nofollow&quot;&gt;bug in the badges plugin&lt;/a&gt; where qa_cookie_get_create() is called:&lt;/p&gt;


&lt;p&gt;
	&lt;span style=&quot;color:#0000ff;&quot;&gt;qa_db_query_sub(
&lt;br&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;'INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) '.
&lt;br&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;'VALUES (NOW(), $, $, $, #, $, $)',
&lt;br&gt;
	&amp;nbsp;&amp;nbsp; &amp;nbsp;qa_remote_ip_address(), $user_id, $handle, &lt;/span&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;qa_cookie_get_create()&lt;/span&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;, 'badge_awarded', 'badge_slug='.$badge_slug.($object_id?&quot;\t&quot;.'postid='.$object_id:'')
&lt;br&gt;
	);&lt;/span&gt;&lt;/p&gt;


&lt;p&gt;
	I replaced &lt;span style=&quot;color:#ff0000;&quot;&gt;qa_cookie_get_create()&lt;/span&gt; with &lt;span style=&quot;color:#ff0000;&quot;&gt;qa_cookie_get() &lt;/span&gt;and would like to know about side effects.&lt;/p&gt;


&lt;p&gt;
	Thank you!
&lt;br&gt;
	Kai&lt;/p&gt;</description>
<category>Q2A Core</category>
<guid isPermaLink="true">https://www.question2answer.org/qa/20520/when-to-use-qa_cookie_get-and-qa_cookie_get_create</guid>
<pubDate>Thu, 10 Jan 2013 09:47:17 +0000</pubDate>
</item>
</channel>
</rss>