<?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>jQueryTips by Tee++; &#187; cookie</title>
	<atom:link href="http://www.jquerytips.com/tag/cookie/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jquerytips.com</link>
	<description>Coding is fun.</description>
	<lastBuildDate>Sun, 25 Apr 2010 11:30:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ปัญหา file_get_contents กับ cookie</title>
		<link>http://www.jquerytips.com/2009/05/14/%e0%b8%9b%e0%b8%b1%e0%b8%8d%e0%b8%ab%e0%b8%b2-file_get_contents-%e0%b8%81%e0%b8%b1%e0%b8%9a-cookie/</link>
		<comments>http://www.jquerytips.com/2009/05/14/%e0%b8%9b%e0%b8%b1%e0%b8%8d%e0%b8%ab%e0%b8%b2-file_get_contents-%e0%b8%81%e0%b8%b1%e0%b8%9a-cookie/#comments</comments>
		<pubDate>Thu, 14 May 2009 05:52:37 +0000</pubDate>
		<dc:creator>TuM</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[file_get_contents]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=443</guid>
		<description><![CDATA[วันก่อนผมจำเป็นต้องใช้ function file_get_contents แต่ไม่สามารถ เรียกใช้หรือแสดง cookie ในหน้านั้นๆ ได้ นั่งมึน !-_- อยู่ตั้งนานกว่าจะหาวิธีได้
ก็จะเอามาให้เพื่อนๆ ดูกันด้วย เผื่อวันใด วัน หนึ่ง จำเป็นต้องได้ใช้กัน



$opts = array&#40;&#8216;http&#8217; =&#62; array&#40;&#8216;header&#8217;=&#62; &#8216;Cookie: &#8216; . $_SERVER&#91;&#8216;HTTP_COOKIE&#8217;&#93;.&#34;\r\n&#34;&#41;&#41;;


&#160;


$context = stream_context_create&#40;$opts&#41;;


&#160;


$contents = file_get_contents&#40;&#91;string filename&#93;, false, $context&#41;;


&#160;


print $contents;




วิธีนี้จะได้ค่า Cookie กลับมาด้วย ปกติถ้าเราใช้ file_get_contents() ก็จะได้แต่ contents มาเท่านั้น
]]></description>
			<content:encoded><![CDATA[<p>วันก่อนผมจำเป็นต้องใช้ <strong>function file_get_contents</strong> แต่ไม่สามารถ เรียกใช้หรือแสดง <strong>cookie</strong> ในหน้านั้นๆ ได้ นั่งมึน !-_- อยู่ตั้งนานกว่าจะหาวิธีได้<br />
ก็จะเอามาให้เพื่อนๆ ดูกันด้วย เผื่อวันใด วัน หนึ่ง จำเป็นต้องได้ใช้กัน</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$opts</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;http&#8217;</span> =&gt; <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;header&#8217;</span>=&gt; <span class="st0">&#8216;Cookie: &#8216;</span> . <span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st0">&#8216;HTTP_COOKIE&#8217;</span><span class="br0">&#93;</span>.<span class="st0">&quot;<span class="es0">\r</span><span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$context</span> = <a href="http://www.php.net/stream_context_create"><span class="kw3">stream_context_create</span></a><span class="br0">&#40;</span><span class="re0">$opts</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="re0">$contents</span> = <a href="http://www.php.net/file_get_contents"><span class="kw3">file_get_contents</span></a><span class="br0">&#40;</span><span class="br0">&#91;</span>string filename<span class="br0">&#93;</span>, <span class="kw2">false</span>, <span class="re0">$context</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/print"><span class="kw3">print</span></a> <span class="re0">$contents</span>;</div>
</li>
</ol>
</div>
<p><span id="more-443"></span></p>
<p>วิธีนี้จะได้ค่า <strong>Cookie </strong>กลับมาด้วย ปกติถ้าเราใช้ <strong>file_get_contents</strong>() ก็จะได้แต่ contents มาเท่านั้น</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2009/05/14/%e0%b8%9b%e0%b8%b1%e0%b8%8d%e0%b8%ab%e0%b8%b2-file_get_contents-%e0%b8%81%e0%b8%b1%e0%b8%9a-cookie/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
