<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: 增加PHP的Session存储和处理能力</title>
	<atom:link href="http://www.toplee.com/blog/300.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.toplee.com/blog/300.html</link>
	<description>活到老，学到老 ...   @ IT，业界，互联网</description>
	<lastBuildDate>Mon, 06 Sep 2010 04:34:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Michael</title>
		<link>http://www.toplee.com/blog/300.html/comment-page-1#comment-31706</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 04 Sep 2009 10:03:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.toplee.com/blog/archives/300.html#comment-31706</guid>
		<description>最新的session共享和性能提升将使用memcached来存储session，见php.ini的文档部分就明白了，可以设置多个memcached给php的session来使用，并且可以配置各个mc的权重，这是我们现在主流的使用手段。</description>
		<content:encoded><![CDATA[<p>最新的session共享和性能提升将使用memcached来存储session，见php.ini的文档部分就明白了，可以设置多个memcached给php的session来使用，并且可以配置各个mc的权重，这是我们现在主流的使用手段。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.toplee.com/blog/300.html/comment-page-1#comment-25804</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Sat, 29 Mar 2008 04:09:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.toplee.com/blog/archives/300.html#comment-25804</guid>
		<description>[Comment ID #25801 Will Be Quoted Here]

最新的pecl_memcached 扩展可以支持直接在php.ini里面设置类似这样的东西：
session.save_handler = memcache
session.save_path = &quot;tcp://host:port?persistent=1&amp;weight=2&amp;timeout=2&amp;retry_interval=15,tcp://host2:port2&quot;
 
比如设置：session.save_path = &quot;tcp://127.0.0.1:11211&quot;， 连接本机上11211端口的memcached来存储session

详细的语法可以参考官方文档 &lt;a href=&quot;http://cvs.php.net/viewvc.cgi/pecl/memcache/php_memcache.h?view=log&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;php_memcache.h cvs log
&lt;/a&gt;</description>
		<content:encoded><![CDATA[<blockquote class='comment_quote'><p><a href="http://www.toplee.com/blog/300.html#comment-25801" title="Click here to view the original comment"><em>逆雪寒 on March 29, 2008 at 11:17 am said:</em></a></p>
<p>我 PHP.INI 知道有这个设置。但真不知道可以设置散列目录储存。<br />
一般我用session_sa&#8230;</p></blockquote>
<p>最新的pecl_memcached 扩展可以支持直接在php.ini里面设置类似这样的东西：<br />
session.save_handler = memcache<br />
session.save_path = &#8220;tcp://host:port?persistent=1&#038;weight=2&#038;timeout=2&#038;retry_interval=15,tcp://host2:port2&#8243;</p>
<p>比如设置：session.save_path = &#8220;tcp://127.0.0.1:11211&#8243;， 连接本机上11211端口的memcached来存储session</p>
<p>详细的语法可以参考官方文档 <a href="http://cvs.php.net/viewvc.cgi/pecl/memcache/php_memcache.h?view=log" target="_blank" rel="nofollow">php_memcache.h cvs log<br />
</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 逆雪寒</title>
		<link>http://www.toplee.com/blog/300.html/comment-page-1#comment-25801</link>
		<dc:creator>逆雪寒</dc:creator>
		<pubDate>Sat, 29 Mar 2008 03:17:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.toplee.com/blog/archives/300.html#comment-25801</guid>
		<description>我 PHP.INI 知道有这个设置。但真不知道可以设置散列目录储存。
一般我用session_save_path  不过好象这个函数并不支持目录散列。呵呵</description>
		<content:encoded><![CDATA[<p>我 PHP.INI 知道有这个设置。但真不知道可以设置散列目录储存。<br />
一般我用session_save_path  不过好象这个函数并不支持目录散列。呵呵</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.toplee.com/blog/300.html/comment-page-1#comment-13358</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Mon, 09 Apr 2007 12:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.toplee.com/blog/archives/300.html#comment-13358</guid>
		<description>[Comment ID #13354 Will Be Quoted Here]

这位朋友说得很对，我用数据库保存过，为了多台机器共享session，用memcached原理一样，就是存储和读取的时候把从数据库改成从memcached操作，另外还可以使用共享内存，比如PHP的APC扩展。</description>
		<content:encoded><![CDATA[<blockquote class='comment_quote'><p><a href="http://www.toplee.com/blog/300.html#comment-13354" title="Click here to view the original comment"><em>Charles on April 9, 2007 at 3:36 pm said:</em></a></p>
<p>有一个将 PHP Session 利用 memcached 来保存的类。好像是一个丹麦的人写的。  &#8230;</p></blockquote>
<p>这位朋友说得很对，我用数据库保存过，为了多台机器共享session，用memcached原理一样，就是存储和读取的时候把从数据库改成从memcached操作，另外还可以使用共享内存，比如PHP的APC扩展。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles</title>
		<link>http://www.toplee.com/blog/300.html/comment-page-1#comment-13354</link>
		<dc:creator>Charles</dc:creator>
		<pubDate>Mon, 09 Apr 2007 07:36:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.toplee.com/blog/archives/300.html#comment-13354</guid>
		<description>有一个将 PHP Session 利用 memcached 来保存的类。好像是一个丹麦的人写的。  :)</description>
		<content:encoded><![CDATA[<p>有一个将 PHP Session 利用 memcached 来保存的类。好像是一个丹麦的人写的。  <img src='http://www.toplee.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.toplee.com/blog/300.html/comment-page-1#comment-7115</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Sun, 22 Oct 2006 05:32:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.toplee.com/blog/archives/300.html#comment-7115</guid>
		<description>说实话，我仔细看了您的留言，但是我还没有搞明白你到底想实现的需求和功能，从你的代码来看，很少看到这样使用cookie和session的，不知道是为了满足什么需求，通常来说，session在我们的应用里面，迫不得已才使用，比如验证码图片，别的地方如果要使用到session，我们都是使用自己开发的session管理，session存储在内存数据库中。
如有可能，你可以再把要实现的需求整理一下告知。</description>
		<content:encoded><![CDATA[<p>说实话，我仔细看了您的留言，但是我还没有搞明白你到底想实现的需求和功能，从你的代码来看，很少看到这样使用cookie和session的，不知道是为了满足什么需求，通常来说，session在我们的应用里面，迫不得已才使用，比如验证码图片，别的地方如果要使用到session，我们都是使用自己开发的session管理，session存储在内存数据库中。<br />
如有可能，你可以再把要实现的需求整理一下告知。</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: diogin</title>
		<link>http://www.toplee.com/blog/300.html/comment-page-1#comment-6924</link>
		<dc:creator>diogin</dc:creator>
		<pubDate>Thu, 19 Oct 2006 15:47:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.toplee.com/blog/archives/300.html#comment-6924</guid>
		<description>啊，奇怪，源代码怎么给过滤掉了？
那再发一次，不好意思:)

index.php:

session_save_path(&#039;./&#039;);
session_name(&#039;DIOGIN_SESSID&#039;);
session_start();
$_SESSION[&#039;diogin&#039;] = &#039;haha&#039;;
header(&#039;Location: diogin.php&#039;);

diogin.php:

session_save_path(&#039;./&#039;);
session_name(&#039;DIOGIN_SESSID&#039;);
if (isset($_COOKIE[&#039;DIOGIN_SESSID&#039;])) {
    session_start();
    $_SESSION = array();
    session_destroy();
    setcookie(&#039;DIOGIN_SESSID&#039;, false);
    header(&#039;Location: another.php&#039;);
}

another.php:

var_dump($_COOKIE);</description>
		<content:encoded><![CDATA[<p>啊，奇怪，源代码怎么给过滤掉了？<br />
那再发一次，不好意思:)</p>
<p>index.php:</p>
<p>session_save_path(&#8216;./&#8217;);<br />
session_name(&#8216;DIOGIN_SESSID&#8217;);<br />
session_start();<br />
$_SESSION['diogin'] = &#8216;haha&#8217;;<br />
header(&#8216;Location: diogin.php&#8217;);</p>
<p>diogin.php:</p>
<p>session_save_path(&#8216;./&#8217;);<br />
session_name(&#8216;DIOGIN_SESSID&#8217;);<br />
if (isset($_COOKIE['DIOGIN_SESSID'])) {<br />
    session_start();<br />
    $_SESSION = array();<br />
    session_destroy();<br />
    setcookie(&#8216;DIOGIN_SESSID&#8217;, false);<br />
    header(&#8216;Location: another.php&#8217;);<br />
}</p>
<p>another.php:</p>
<p>var_dump($_COOKIE);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: diogin</title>
		<link>http://www.toplee.com/blog/300.html/comment-page-1#comment-6923</link>
		<dc:creator>diogin</dc:creator>
		<pubDate>Thu, 19 Oct 2006 15:44:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.toplee.com/blog/archives/300.html#comment-6923</guid>
		<description>不错，以前就注意到这个功能，不过一直没试过，现在正好一试:)
另外，关于session，我遇到了一个调试了几乎一个下午也没解决的问题，不知Michael有没有遇到过，简单地说就是下面的三段代码：

index.php:



diogin.php:



another.php:



这样，访问index.php，将新建一个session，然后删除，再检查cookie数组。这三段代码是能正常工作的，可以把session使用的cookie删除。但当我把类似的代码集成进系统后，想用setcookie来删除会话cookie，就行不通，调试了一下午都没解决。不知这里是不是有什么需要注意的事情我没察觉到，Michael遇到过类似的情况吗？</description>
		<content:encoded><![CDATA[<p>不错，以前就注意到这个功能，不过一直没试过，现在正好一试:)<br />
另外，关于session，我遇到了一个调试了几乎一个下午也没解决的问题，不知Michael有没有遇到过，简单地说就是下面的三段代码：</p>
<p>index.php:</p>
<p>diogin.php:</p>
<p>another.php:</p>
<p>这样，访问index.php，将新建一个session，然后删除，再检查cookie数组。这三段代码是能正常工作的，可以把session使用的cookie删除。但当我把类似的代码集成进系统后，想用setcookie来删除会话cookie，就行不通，调试了一下午都没解决。不知这里是不是有什么需要注意的事情我没察觉到，Michael遇到过类似的情况吗？</p>
]]></content:encoded>
	</item>
</channel>
</rss>
