<?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>[LINICKX].com &#187; tutorial</title>
	<atom:link href="http://www.linickx.com/tag/tutorial/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linickx.com</link>
	<description>Moments of Genius followed by Trash.</description>
	<lastBuildDate>Thu, 17 May 2012 10:23:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>root-cookie &#8211; Tutorial 1: Accessing WordPress cookies from custom scripts.</title>
		<link>http://www.linickx.com/1016/root-cookie-tutorial-1-accessing-wordpress-cookies-from-custom-scripts</link>
		<comments>http://www.linickx.com/1016/root-cookie-tutorial-1-accessing-wordpress-cookies-from-custom-scripts#comments</comments>
		<pubDate>Fri, 08 May 2009 07:08:10 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[root-cookie]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.linickx.com/?p=1016</guid>
		<description><![CDATA[I&#8217;ve been wanting to do this for a while, this is the 1st in a planned short series of tutorials for my root cookie WordPress plugin. I&#8217;ve decided to start with the purpose I wrote the plugin, then I&#8217;ll move &#8230; <a href="http://www.linickx.com/1016/root-cookie-tutorial-1-accessing-wordpress-cookies-from-custom-scripts">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been wanting to do this for a while, this is the 1st in a planned short series of tutorials for <a href="http://wordpress.org/extend/plugins/root-cookie/">my root cookie WordPress plugin</a>.</p>
<p>I&#8217;ve decided to start with the purpose I wrote the plugin, then I&#8217;ll move onto a couple of tutorial which answer some of the FAQs I get.</p>
<p><strong>Scenario.</strong><br />
Before you start you need a working copy BLANK of WordPress, in a sub directory, with a url like domain.com/wordpress.<br />
A BLANK copy is a fresh install, using the default theme and only my root-cookie plugin installed, remember after activating the plugin clear your browsers cookies.</p>
<p><strong>Getting Started.</strong><br />
So you have a ready &#038; waiting copy of WP, next create a directory called &#8220;my-scripts&#8221; or whatever you like, and in it create 1.php with the following contents:</p>
<p><code><br />
&lt;?php<br />
print_r($_COOKIE);<br />
?&gt;<br />
</code></p>
<p>Browse to domain.com/my-scripts/1.php and you&#8217;ll get a blank white page with <code>Array()</code>.<br />
Next log into WordPress, and re-fresh 1.php and you should get something like&#8230;.</p>
<blockquote><p>
Array ( [wordpress_xxxxxxxxxxxxxyyyyyyyyyyyyyy] => admin|1241455565|xxxxxxxxxxxxxyyyyyyyyyyyyyy [wordpress_logged_in_xxxxxxxxxxxxxyyyyyyyyyyyyyy] => admin|1241455565|xxxxxxxxxxxxxyyyyyyyyyyyyyy )
</p></blockquote>
<p>Done! You&#8217;ve just accessed WordPress&#8217;s cookies <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now when I first started I had a very basic script which hid my Google adverts when I&#8217;m logged in, it&#8217;s against Google&#8217;s policies to click on your own adverts so to avoid accidents I wanted to hide them. </p>
<p>The following script is NOT secure, it doesn&#8217;t check that you&#8217;ve logged into WordPress it simply checks that you a cookie set with the right username (<em>which anyone can fake</em>) but for my purpose this was fine, I had no issues with users faking cookies to get rid of the adverts*</p>
<p><code><br />
&lt;?php<br />
if (isset($_COOKIE["wordpress_logged_in_fxxxxxxxxxxxxxyyyyyyyyyyyyyy"])) {<br />
        $cookie = $_COOKIE["wordpress_logged_in_xxxxxxxxxxxxxyyyyyyyyyyyyyy"];<br />
        $cookie_elements = explode('|', $cookie);<br />
        if ($cookie_elements[0] == "admin") {<br />
                echo "&lt;h1&gt;Hello admin!< &lt;/h1&gt;";<br />
        }<br />
}<br />
?&gt;<br />
</code></p>
<p>Replace admin with whatever username your using and job done! Next time Accessing two WordPress installs domain.com/blog1 domain.com/blog2 with root-cookie <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>*<em>this will not work now, as I do something different.</em> <img src='http://www.linickx.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p></code></p>
<img src="http://www.linickx.com/wp/wp-content/themes/linickx_v2/images/nick_sig_bggrey.png" alt="Nick" /> <hr/>Copyright &copy; 2012 <strong><a href="http://www.linickx.com">[LINICKX].com</a></strong>. This Feed is for personal non-commercial use only. Please check my <a href="http://www.linickx.com/?page_id=63">Site Terms and Conditions</a> for full details on copyrights. If you have any concerns with the content of this feed you may <a href="http://www.linickx.com/contact">contact me here</a>.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">WP Copyright Plugin</a></span>]]></content:encoded>
			<wfw:commentRss>http://www.linickx.com/1016/root-cookie-tutorial-1-accessing-wordpress-cookies-from-custom-scripts/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

