<?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>Benzing Web Design Marketing &#187; PHP / MySQL</title>
	<atom:link href="http://www.benzingtech.com/blog/php-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.benzingtech.com</link>
	<description>Fort Myers Naples Website Design Web Hosting SEO</description>
	<lastBuildDate>Tue, 31 Jan 2012 04:20:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Google URL Shortening Service PHP Script</title>
		<link>http://www.benzingtech.com/google-url-shortening-service-php-script/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-url-shortening-service-php-script</link>
		<comments>http://www.benzingtech.com/google-url-shortening-service-php-script/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 17:37:42 +0000</pubDate>
		<dc:creator>Rusty</dc:creator>
				<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[google qr code]]></category>
		<category><![CDATA[google url shorten]]></category>
		<category><![CDATA[php google code]]></category>
		<category><![CDATA[php short url]]></category>

		<guid isPermaLink="false">http://www.benzingtech.com/?p=2324</guid>
		<description><![CDATA[<p><p><a href="http://www.benzingtech.com/google-url-shortening-service-php-script/">Google URL Shortening Service PHP Script</a></p><p><p>Google&#8217;s URL Shortener has been used by Google services like FeedBurner, Google News, Blogger to share links on Twitter. Google didn&#8217;t provide a web interface for the service, but third-party sites managed to fill the void.</p>
<p>Now you can go to goo.gl, paste any web address and get a short &#8230;</p></p></p><p><a href="http://www.benzingtech.com">Benzing Web Design Marketing</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.benzingtech.com/google-url-shortening-service-php-script/">Google URL Shortening Service PHP Script</a></p><p>Google&#8217;s URL Shortener has been used by Google services like FeedBurner, Google News, Blogger to share links on Twitter. Google didn&#8217;t provide a web interface for the service, but third-party sites managed to fill the void.</p>
<p>Now you can go to goo.gl, paste any web address and get a short URL. Google also shows stats for any short URL generated using the service: append &#8220;.info&#8221; to the address and you&#8217;ll see the number of clicks, a list of traffic sources and some aggregate information about visitors.</p>
<p>So where do you start? well if you don&#8217;t have a google account <a href="https://accounts.google.com/NewAccount" title="get a google account" target="_blank">signup now</a> and then get an <a href="https://code.google.com/apis/console/" title="Get a API Key" target="_blank">API Key</a>.</p>
<p>If you sign in to a Google account, Google will save a list of recently generated URLs. Another advantage is that Google will always generate unique URLs when you are logged in, so that the stats are more useful.</p>
<p>Now that you have your google account and API Key we need to create some PHP code that will grab our short url and display it. First, I’ll walk you through on how it’s done, then I’ll give the full script at the end. Let’s start off with what we need, and that is, the URL that you want to shorten.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://benzingtech.com/fort-myers-web-design/'</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you want to associate the shortened urls to your Google account, just put it your email address and password. You can also add in a Google API key if you have one. Remember, these values are optional.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$email</span>    <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// OPTIONAL: GMail or Google Apps email address</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// OPTIONAL: Your Password for above account</span>
<span style="color: #000088;">$api_key</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Required</span></pre></div></div>

<p>Next thing we do is use Google’s ClientLogin API to get an Auth key for us to authenticate our requests later. Notice the POST parameters that we include in the request, as required by the API. See the <a href="http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html" target="_blank">ClientLogin documentation</a> to view other details. For this example I used the <a href="http://sudocode.net/sources/includes/class-xhttp-php/" title="Sudocode" target="_blank">Sudocode xhttp class</a> to fetch my results.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span> and <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'accountType'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'HOSTED_OR_GOOGLE'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'Email'</span>       <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$email</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'Passwd'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$password</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'service'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'urlshortener'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'source'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'benzingtech-example-v1'</span> <span style="color: #666666; font-style: italic;">// Application's name, e.g. companyName-applicationName-versionID</span>
      <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> xhttp<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'https://www.google.com/accounts/ClientLogin'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>One <strong>IMPORTANT</strong> note is the service parameter, &#8220;urlshortener&#8221;, which is undocumented. </p>
<p>If the request was successful, it will return three lines of text; one for each key: SID, LSID and Auth.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">SID=DQAAAGgA...7Zg8CTN
LSID=DQAAAGsA...lk8BBbG
Auth=DQAAAGgA...dk3fA5N</pre></div></div>

<p>The lines are way much longer than the example above. If not successful, refer to the documention for the error codes you might get when trying to login. We just need the Auth key for our script and we use PHP&#8217;s function preg_match to extract it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/Auth=(.+)/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'body'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$auth</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here is why I said earlier that I don’t advise using the code as-is, the Auth key can be cached for a long time, as long as you use it regularly. Be sure to cache your Auth Key between sequential requests to minimize URL fetches thus making your app faster and use less processes.</p>
<p>Now that we got our Auth key, and URL to shorten finally, we ask goo.gl to shorten our long URL. We pass off the Auth key in the Authorization header.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$auth</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'headers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Authorization'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;GoogleLogin auth=<span style="color: #006699; font-weight: bold;">$auth</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$api_key</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'get'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'key'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$api_key</span><span style="color: #339933;">;</span></pre></div></div>

<p>We set the correct Content-Type (application/json), as expected by the API. My xhttp class takes care of converting the array to a JSON string.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'headers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Content-Type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
   <span style="color: #0000ff;">'longUrl'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$url</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> xhttp<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;https://www.googleapis.com/urlshortener/v1/url&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Congrats you are Done. We could retrieve the short url by decoding the response and getting the id field like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'body'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$shortURL</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$shortURL</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Note: that a new URL is generated for each request even if you shorten the same long URL if you do not use the API Key</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://benzingtech.com/fort-myers-web-design/'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$email</span>    <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// OPTIONAL: GMail or Google Apps email address</span>
<span style="color: #000088;">$password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// OPTIONAL: Your Password for above account</span>
<span style="color: #000088;">$api_key</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Required</span>
&nbsp;
<span style="color: #b1b100;">require</span> <span style="color: #0000ff;">'class.xhttp.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$email</span> and <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'accountType'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'HOSTED_OR_GOOGLE'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'Email'</span>       <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$email</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'Passwd'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$password</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'service'</span>     <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'urlshortener'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'source'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'benzingtech-example-v1'</span> <span style="color: #666666; font-style: italic;">// Application's name, e.g. companyName-applicationName-versionID</span>
      <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> xhttp<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'https://www.google.com/accounts/ClientLogin'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Check if login failed</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'successful'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Login Failed<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/Auth=(.+)/'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'body'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$auth</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$auth</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'headers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Authorization'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;GoogleLogin auth=<span style="color: #006699; font-weight: bold;">$auth</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$api_key</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'get'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'key'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$api_key</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'headers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Content-Type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
   <span style="color: #0000ff;">'longUrl'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$url</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> xhttp<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;https://www.googleapis.com/urlshortener/v1/url&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'successful'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'body'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$shortURL</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$shortURL</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><a href="http://www.benzingtech.com">Benzing Web Design Marketing</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.benzingtech.com/google-url-shortening-service-php-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use PHP to Ping Technorati on your blog updates</title>
		<link>http://www.benzingtech.com/use-php-to-ping-technorati-on-your-blog-updates/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=use-php-to-ping-technorati-on-your-blog-updates</link>
		<comments>http://www.benzingtech.com/use-php-to-ping-technorati-on-your-blog-updates/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 15:15:21 +0000</pubDate>
		<dc:creator>Rusty</dc:creator>
				<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[Social Networking]]></category>
		<category><![CDATA[blog ping]]></category>
		<category><![CDATA[how to write a php code to ping search engines]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php blog ping]]></category>
		<category><![CDATA[php ping]]></category>
		<category><![CDATA[php ping blog scripts xml-rpc]]></category>
		<category><![CDATA[php ping xmlrpc client -pear]]></category>
		<category><![CDATA[php send a ping request]]></category>
		<category><![CDATA[php weblogupdates.ping]]></category>
		<category><![CDATA[ping in php]]></category>
		<category><![CDATA[ping technorati]]></category>
		<category><![CDATA[ping with php]]></category>
		<category><![CDATA[ping your blog via xml-rpc with php]]></category>
		<category><![CDATA[technorati ping php]]></category>
		<category><![CDATA[weblogupdates.ping]]></category>
		<category><![CDATA[why r we using -t ping]]></category>
		<category><![CDATA[xml-rpc]]></category>

		<guid isPermaLink="false">http://www.benzingtech.com/?p=873</guid>
		<description><![CDATA[<p><p><a href="http://www.benzingtech.com/use-php-to-ping-technorati-on-your-blog-updates/">Use PHP to Ping Technorati on your blog updates</a></p><p><p>If you are familiar with blogosphere you know what is Technorati.</p>
<p>Technorati is an Internet search engine for searching blogs. You can submit your blog to Technorati and ping their servers when your blog site is updated. when you ping Technorati their web crawlers read the updated information on your &#8230;</p></p></p><p><a href="http://www.benzingtech.com">Benzing Web Design Marketing</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.benzingtech.com/use-php-to-ping-technorati-on-your-blog-updates/">Use PHP to Ping Technorati on your blog updates</a></p><p>If you are familiar with blogosphere you know what is Technorati.</p>
<p>Technorati is an Internet search engine for searching blogs. You can submit your blog to Technorati and ping their servers when your blog site is updated. when you ping Technorati their web crawlers read the updated information on your site.</p>
<p>Technorati offers an XML-RPC ping web service to allow blogs to notify content changes.</p>
<p>In this article we discuss how to write a PHP script to programatically ping Technorati when there is new content in your site.</p>
<p>The URL to ping is rpc.technorati.com/rpc/ping.</p>
<p>The method name to call is weblogUpdates.ping.</p>
<p>The request XML must contain two parameters &#8211; your blog site name the blog site URL.</p>
<p>From the <a href="http://technorati.com/developers/ping/">API documentation</a> of Technorati, the sample request XML is as below:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
  weblogUpdates.ping
  YOUR WEBLOG NAME HERE
  http://www.YOURWEBLOGURL.com/</pre></div></div>

<p>Let&#8217;s start writing the XML-RPC client to ping Technorati.</p>
<p>Our first step is to generate the required XML request string.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$site_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YOUR WEBLOG NAME HERE&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$site_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://www.YOURWEBLOGURL.com&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #990000;">xmlrpc_encode_request</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;weblogUpdates.ping&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$site_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$site_url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The function xmlrpc_encode_request as the name suggests, creates the request XML string. If you echo $request variable you will see output like below:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;iso-8859-1&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
&nbsp;
weblogUpdates.ping
&nbsp;
   Benzing Technologies
&nbsp;
   http://benzingtech.com</pre></div></div>

<p>The next step is to create the streams context.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$context</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stream_context_create</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'method'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;POST&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'header'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Content-Type: text/xml<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>User-Agent: PHPRPC/1.0<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>Host: rpc.technorati.com<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'content'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$request</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The code snippet states that we are preparing to make an HTTP POST request to the server rpc.technorati.com.</p>
<p>The next step is to make the request.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$server</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://rpc.technorati.com/rpc/ping&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$server</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$context</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>We now decode the response XML using the function xmlrpc_decode(). We determine whether the response XML contains a fault structure using the xmlrpc_is_fault() function.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #990000;">xmlrpc_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span> and <span style="color: #990000;">xmlrpc_is_fault</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Failed to ping Technorati&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Successfully pinged Technorati&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The entire script is pasted below.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$site_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Benzing Technologies&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * The URL of your site
 */</span>
<span style="color: #000088;">$site_url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://benzingtech.com&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #990000;">xmlrpc_encode_request</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;weblogUpdates.ping&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$site_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$site_url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#echo $request;
</span>
<span style="color: #000088;">$context</span> <span style="color: #339933;">=</span> <span style="color: #990000;">stream_context_create</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'method'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;POST&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'header'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Content-Type: text/xml<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>User-Agent: PHPRPC/1.0<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>Host: rpc.technorati.com<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'content'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$request</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$server</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://rpc.technorati.com/rpc/ping&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$server</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$context</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #990000;">xmlrpc_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span> and <span style="color: #990000;">xmlrpc_is_fault</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Failed to ping Technorati&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Successfully pinged Technorati&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>The source code is available from the <a href="http://github.com/bngsudheer/Code-Album/blob/47b908538d6c60e4056fcaee06461a37e46e7506/cli/scripts/standalone/service/Technorati/Ping.php">Code Album</a> Github repository.</p>
<p><a href="http://www.benzingtech.com">Benzing Web Design Marketing</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.benzingtech.com/use-php-to-ping-technorati-on-your-blog-updates/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to Create Totally Secure Cookies</title>
		<link>http://www.benzingtech.com/how-to-create-totally-secure-cookies/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-create-totally-secure-cookies</link>
		<comments>http://www.benzingtech.com/how-to-create-totally-secure-cookies/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 03:36:51 +0000</pubDate>
		<dc:creator>Rusty</dc:creator>
				<category><![CDATA[PHP / MySQL]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[creating secure cookies in javascript]]></category>
		<category><![CDATA[creating secure cookies with php]]></category>
		<category><![CDATA[how to create secure cookies]]></category>
		<category><![CDATA[secure cookies]]></category>
		<category><![CDATA[securing cookies in web applications]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://benzingtech.com/?p=785</guid>
		<description><![CDATA[<p><p><a href="http://www.benzingtech.com/how-to-create-totally-secure-cookies/">How to Create Totally Secure Cookies</a></p><p><p>Originally Posted at Carsonified.com</p>
<p>Securing cookies and sessions is vital to keeping an application secure. Many tutorials have been written on the subject, but as the internet (and browsers loading it) evolve so do the methods you can use to keep your application secure.</p>
<p>In this article we’re going to &#8230;</p></p></p><p><a href="http://www.benzingtech.com">Benzing Web Design Marketing</a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.benzingtech.com/how-to-create-totally-secure-cookies/">How to Create Totally Secure Cookies</a></p><p>Originally Posted at <a href="http://carsonified.com/blog/dev/how-to-create-totally-secure-cookies/" target="_blank">Carsonified.com</a></p>
<p>Securing cookies and sessions is vital to keeping an application secure. Many tutorials have been written on the subject, but as the internet (and browsers loading it) evolve so do the methods you can use to keep your application secure.</p>
<p>In this article we’re going to break down the various components of a cookie and what they mean for security. This will include limiting the cookie to certain domains and paths on those domains, choosing what information to store, and protecting the cookie from cross site scripting exploits. In a second article we will go into more depth in how to protect everyone’s favorite cookie, the session ID.</p>
<p><strong>How Cookies Work</strong></p>
<p>Cookies are simply key/value pairs that let us get around HTTP being a stateless protocol. When a developer has data they wish to last for more than one connection they can use cookies to store that data on the client side. While this tends to get handled by the programming language being used it is accomplished using HTTP headers.</p>
<p>When the server wants to set a cookie it passes back a header named “Set-Cookie” with the key-value pair and some options.</p>
<p><img class="alignnone size-medium wp-image-786" title="bigger-liveheaders-setcookie" src="http://benzingtech.com/wp-content/uploads/2009/08/bigger-liveheaders-setcookie-300x260.png" alt="bigger-liveheaders-setcookie" width="300" height="260" /><br />
<a href="http://benzingtech.com/wp-content/uploads/2009/08/bigger-liveheaders-setcookie.png" target="_blank">View larger</a></p>
<p>On subsequent requests the client will send along its own header to let the server know the name and value of its stored cookies. The server will not continue to send back the cookies, it will only send them if there is a change.</p>
<p><img class="alignnone size-medium wp-image-787" title="bigger-liveheaders-clientcookie" src="http://benzingtech.com/wp-content/uploads/2009/08/bigger-liveheaders-clientcookie-300x260.png" alt="bigger-liveheaders-clientcookie" width="300" height="260" /><br />
<a href="http://benzingtech.com/wp-content/uploads/2009/08/bigger-liveheaders-clientcookie.png" target="_blank">View larger</a></p>
<p>You can see all the headers for yourself using the LiveHeaders plugin for Firefox.<br />
The Problem</p>
<p>This data is completely in control of the client- it is trivial to change the values of a cookie. That means that, just like post and get data, all cookie data must be validated in some way. At the same time you’ll want to avoid storing sensitive information, such as passwords, as cookies are stored in cleartext and anyone with access to the computer later can easily pick those up (I know of at least one security forum that was hacked in this way). It is also important to note that HTTP does not encrypt the headers in any way. If the connection isn’t over SSL then it will not be protected from snooping eyes.</p>
<p>Session cookies are no different than any other cookie- their value is just a simple ID. Those IDs are susceptible to all of the same limitations as other cookies. The real power behind sessions happens server side, where the ID is used to pull out data stored on the server. This has many benefits over storing data directly into the cookie itself- data can’t be manipulated by the user, large amount of data can be stored without having to send it back and forth with each request, and you can store data you otherwise wouldn’t want the client to have access to.<br />
Getting Started</p>
<p>The first step towards securing your cookie is to restrict that cookie to only your application. This is especially important in environments that support multiple sites or applications (the type of shared hosting you often see on corporate or university domains). By restricting the cookie to only the applications that need it you reduce the chances of it being sniffed while also keeping the cookie namespaces clear for other applications that use them.</p>
<p>There are three options that can be sent along when creating a cookie that, when used properly, will keep the cookie limited to only your application. Before setting these options you will need to ask yourself a few questions-</p>
<ul>
<li> What parts of the website need access to the cookie?</li>
<li> Will the cookie need to work across sub domains?</li>
<li> Will the cookie need to persist if the user leaves an SSL portion of the site?</li>
</ul>
<p>There is also a forth option used by newer browsers to restrict access to cookies by javascript.</p>
<p>As you will see, how exactly to restrict the cookie really does depend on the exact purpose for that cookie. A banking or ecommerce site may restrict their cookies to only SSL, while a blog or news aggregator may want to leave things more open.<br />
Cookie Options</p>
<p><strong>Send The Cookie To Only Your Application</strong></p>
<p>The Path argument specifies what paths on the site to send the cookie. The default value of “/” means every request will get the cookie, while “/forums/” would limit the cookie to just that path. This path is going to be based on the actual URL the browser uses, before any mod_rewrite or other URL mapping.</p>
<p><strong>Don’t Share With Sub Domains</strong></p>
<p>The Domain option allows you to specify whether or not to send the cookie to subdomains. Setting “www.example.com” will mean only the exact domain “www.example.com” will be matched, while “.example.com” will also match again any subdomaim (forums.example.com, blog.example.com).</p>
<p><strong>Require a Secure Connection</strong></p>
<p>Using the Secure option you can tell the browser (or other http clients) to only send the cookie over SSL connections. This means the cookie will not be available to any part of the site that is not secure will not have access to the cookie, but it also makes it much less likely that you’ll accidentally send the cookie across as cleartext.</p>
<p><strong>Protect Against XSS Exploits</strong></p>
<p>This HttpOnly flag is used to tell the browser that it should not allow javascript to access the contents of the cookie. This is primarily a defense against cross site scripting, as it will prevent hackers from being able to retrieve and use the session through such an attack.</p>
<p>The HttpOnly option is not by any means full proof. As a client-side defense mechanism it relies on browser support to work, but is only supported by a few browsers (Firefox 3+ and IE 7+, with partial support from Opera 9.5, IE6 and Chrome).</p>
<p><strong>Configuring the Cookie</strong></p>
<p>In PHP, setting the arguments for cookies is done through some optional arguments on the “setcookie” function:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">setcookie( name, value, expire, path, domain, secure, httponly);
&nbsp;
// Open
setcookie( 'UserName', 'Bob', 0, '/', '.example', false, false);
&nbsp;
// Locked Down
setcookie( 'UserName', 'Bob', 0, '/forums', 'www.example.com', isset($_SERVER[&quot;HTTPS&quot;]), true);</pre></div></div>

<p>To change the cookie values for the session cookie requires the “session_set_cookie_params” function, which needs to be called before the session is started.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">session_set_cookie_params($expire, $path, $domain, $secure, true);
&nbsp;
// Open
session_set_cookie_params(0, '/', '.example', false, false);
&nbsp;
// Locked Down
session_set_cookie_params('o, /forums', 'www.example.com', isset($_SERVER[&quot;HTTPS&quot;]), true)</pre></div></div>

<p><strong>Summary</strong></p>
<p>Cookies remain the basic method of identify tracking on most websites and keeping them secure is a vital part to keeping applications as a whole locked down and secure. In this article we went over four methods for protecting cookies on a general level.</p>
<p>When using cookies its important to remember to:</p>
<ul>
<li> Limit the amount of sensitive information stored in the cookie.</li>
<li> Limit the subdomains and paths to prevent interception by another application.</li>
<li> Enforce SSL so the cookie isn’t sent in cleartext.</li>
<li> Make the cookie HttpOnly so its not accessible to javascript.</li>
</ul>
<p>Please check out the second half of this series, where we’re going to take the next step with an in depth guide to securing sessions.</p>
<h4>Related Blogs</h4>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <strong>cookies</strong></li>
<li><a href="http://blog.kingarthurflour.com/2009/08/23/no-brag-just-fact-these-butter-pecan-cookies-are-da-bomb/">No brag, just fact: these butter-pecan <strong>cookies</strong> are DA BOMB. | King <strong>&#8230;</strong></a></li>
</ul>
<ul class="pc_pingback">
<li class="hdl" style="list-style: none">Related Blogs on <strong>security</strong></li>
</ul>
<p><a href="http://www.benzingtech.com">Benzing Web Design Marketing</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.benzingtech.com/how-to-create-totally-secure-cookies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

