ess_write($id, $data) { global $DBsess , $DBsess_link, $SESS_LIFE; mysql_select_db($DBsess["dbname"]);
$expiry_time = time() + $SESS_LIFE;
if ( !get_magic_quotes_gpc() ) { $data = addslashes($data); }
$now = time();
$result = mysql_query("INSERT into `sessions` (`id`, `expiry_time`, `data`)", $DBsess_link);
if ( !$result ) { $result = mysql_query("UPDATE `sessions` SET `data`=''$data'', `expiry_time`=$expiry_time WHERE `id` = ''$id'' AND `expiry_time` > $now", $DBsess_link); }
return $result; }
function sess_destroy($id) { global $DBsess , $DBsess_link; mysql_select_db($DBsess["dbname"]); $query = mysql_query("DELETE FROM `session` WHERE `id`=''$id''"); return $query; }
function sess_gc($maxlifetime) { global $DBsess , $DBsess_link; $query = mysql_query("DELETE FROM `sessions` WHERE `expiry_time` < " . time(), $DBsess_link); return mysql_affected_rows($DBsess_link);
}
session_module_name(); session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc");
?>
session_test.php <?php // test for using session include ("common/Common.config.php"); include ("include/session.inc.php");
session_start();
Mysql´æÈ¡sessionʵÀý - ÁèÖڿƼ¼
¿ìËÙÒµÎñͨµÀ
++++Ñ¡ÔñͨµÀ++++
¹úÄÚ·þÎñÆ÷ ÏÃÃŵçÐÅ·þÎñÆ÷ ÉÇÍ·µçÐÅ·þÎñÆ÷ ÎÂÖݵçÐÅ·þÎñÆ÷ ÏÃÃÅÍøͨ·þÎñÆ÷ ÉÇÍ·Ë«Ïß·þÎñÆ÷ ÃÀ¹ú·þÎñÆ÷ Å·ÖÞ·þÎñÆ÷ ÃÀ¹úKT»ú·¿·þÎñÆ÷ ÃÀ¹úFDC»ú·¿·þÎñÆ÷ Ïã¸Û·þÎñÆ÷ мÓÆ·þÎñÆ÷ º«¹ú·þÎñÆ÷ ̨Íå·þÎñÆ÷ Ó¢¹ú·þÎñÆ÷ µÂ¹ú·þÎñÆ÷ мÓÆÂQala»ú·¿·þÎñÆ÷ Ïã¸Û»ú·¿·þÎñÆ÷ ·¨¹ú·þÎñÆ÷ ½ËÕµçÐÅ·þÎñÆ÷ ÃÀ¹úTB»ú·¿·þÎñÆ÷ ÈÕ±¾·þÎñÆ÷ ºÓ±±Íøͨ·þÎñÆ÷ ÏÃÃÅÈí¶þ·þÎñÆ÷ ̨Íå»ú·¿·þÎñÆ÷ º«¹ú»ú·¿·þÎñÆ÷ ÃÀ¹úST»ú·¿·þÎñÆ÷ ½Î÷µçÐÅ·þÎñÆ÷ ÆäËû»ú·¿·þÎñÆ÷ ·ÆÂɱö·þÎñÆ÷ ÈÕ±¾»ú·¿·þÎñÆ÷ ·ÆÂɱö»ú·¿·þÎñÆ÷
¹úÄÚ´ó´ø¿í
Mysql´æÈ¡sessionʵÀý
×÷Õß ØýÃû¼¼Êõ
À´Ô´ NET±à³Ì
ä¯ÀÀ
·¢²¼Ê±¼ä 2012-05-25
content
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn
ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!
SESSION["abc"] = "A: I will be back!";
Mysql´æÈ¡sessionʵÀý - ÁèÖڿƼ¼
¿ìËÙÒµÎñͨµÀ
++++Ñ¡ÔñͨµÀ++++
¹úÄÚ·þÎñÆ÷ ÏÃÃŵçÐÅ·þÎñÆ÷ ÉÇÍ·µçÐÅ·þÎñÆ÷ ÎÂÖݵçÐÅ·þÎñÆ÷ ÏÃÃÅÍøͨ·þÎñÆ÷ ÉÇÍ·Ë«Ïß·þÎñÆ÷ ÃÀ¹ú·þÎñÆ÷ Å·ÖÞ·þÎñÆ÷ ÃÀ¹úKT»ú·¿·þÎñÆ÷ ÃÀ¹úFDC»ú·¿·þÎñÆ÷ Ïã¸Û·þÎñÆ÷ мÓÆ·þÎñÆ÷ º«¹ú·þÎñÆ÷ ̨Íå·þÎñÆ÷ Ó¢¹ú·þÎñÆ÷ µÂ¹ú·þÎñÆ÷ мÓÆÂQala»ú·¿·þÎñÆ÷ Ïã¸Û»ú·¿·þÎñÆ÷ ·¨¹ú·þÎñÆ÷ ½ËÕµçÐÅ·þÎñÆ÷ ÃÀ¹úTB»ú·¿·þÎñÆ÷ ÈÕ±¾·þÎñÆ÷ ºÓ±±Íøͨ·þÎñÆ÷ ÏÃÃÅÈí¶þ·þÎñÆ÷ ̨Íå»ú·¿·þÎñÆ÷ º«¹ú»ú·¿·þÎñÆ÷ ÃÀ¹úST»ú·¿·þÎñÆ÷ ½Î÷µçÐÅ·þÎñÆ÷ ÆäËû»ú·¿·þÎñÆ÷ ·ÆÂɱö·þÎñÆ÷ ÈÕ±¾»ú·¿·þÎñÆ÷ ·ÆÂɱö»ú·¿·þÎñÆ÷
¹úÄÚ´ó´ø¿í
Mysql´æÈ¡sessionʵÀý
×÷Õß ØýÃû¼¼Êõ
À´Ô´ NET±à³Ì
ä¯ÀÀ
·¢²¼Ê±¼ä 2012-05-25
content
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn
ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!
SESSION["meto"] = "B: Me too "; echo "<a href=\"get_session_test.php\">click me</a>";
?>
get_session_test.php
<?php // test for using session include ("common/Common.config.php"); include ("include/session.inc.php");
session_start(); /* * www.knowsky.com */
Mysql´æÈ¡sessionʵÀý - ÁèÖڿƼ¼
¿ìËÙÒµÎñͨµÀ
++++Ñ¡ÔñͨµÀ++++
¹úÄÚ·þÎñÆ÷ ÏÃÃŵçÐÅ·þÎñÆ÷ ÉÇÍ·µçÐÅ·þÎñÆ÷ ÎÂÖݵçÐÅ·þÎñÆ÷ ÏÃÃÅÍøͨ·þÎñÆ÷ ÉÇÍ·Ë«Ïß·þÎñÆ÷ ÃÀ¹ú·þÎñÆ÷ Å·ÖÞ·þÎñÆ÷ ÃÀ¹úKT»ú·¿·þÎñÆ÷ ÃÀ¹úFDC»ú·¿·þÎñÆ÷ Ïã¸Û·þÎñÆ÷ мÓÆ·þÎñÆ÷ º«¹ú·þÎñÆ÷ ̨Íå·þÎñÆ÷ Ó¢¹ú·þÎñÆ÷ µÂ¹ú·þÎñÆ÷ мÓÆÂQala»ú·¿·þÎñÆ÷ Ïã¸Û»ú·¿·þÎñÆ÷ ·¨¹ú·þÎñÆ÷ ½ËÕµçÐÅ·þÎñÆ÷ ÃÀ¹úTB»ú·¿·þÎñÆ÷ ÈÕ±¾·þÎñÆ÷ ºÓ±±Íøͨ·þÎñÆ÷ ÏÃÃÅÈí¶þ·þÎñÆ÷ ̨Íå»ú·¿·þÎñÆ÷ º«¹ú»ú·¿·þÎñÆ÷ ÃÀ¹úST»ú·¿·þÎñÆ÷ ½Î÷µçÐÅ·þÎñÆ÷ ÆäËû»ú·¿·þÎñÆ÷ ·ÆÂɱö·þÎñÆ÷ ÈÕ±¾»ú·¿·þÎñÆ÷ ·ÆÂɱö»ú·¿·þÎñÆ÷
¹úÄÚ´ó´ø¿í
Mysql´æÈ¡sessionʵÀý
×÷Õß ØýÃû¼¼Êõ
À´Ô´ NET±à³Ì
ä¯ÀÀ
·¢²¼Ê±¼ä 2012-05-25
content
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn
ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!
SESSION["c"] = "<br>C: I will follow U. ^0^!"; print(
Mysql´æÈ¡sessionʵÀý - ÁèÖڿƼ¼
¿ìËÙÒµÎñͨµÀ
++++Ñ¡ÔñͨµÀ++++
¹úÄÚ·þÎñÆ÷ ÏÃÃŵçÐÅ·þÎñÆ÷ ÉÇÍ·µçÐÅ·þÎñÆ÷ ÎÂÖݵçÐÅ·þÎñÆ÷ ÏÃÃÅÍøͨ·þÎñÆ÷ ÉÇÍ·Ë«Ïß·þÎñÆ÷ ÃÀ¹ú·þÎñÆ÷ Å·ÖÞ·þÎñÆ÷ ÃÀ¹úKT»ú·¿·þÎñÆ÷ ÃÀ¹úFDC»ú·¿·þÎñÆ÷ Ïã¸Û·þÎñÆ÷ мÓÆ·þÎñÆ÷ º«¹ú·þÎñÆ÷ ̨Íå·þÎñÆ÷ Ó¢¹ú·þÎñÆ÷ µÂ¹ú·þÎñÆ÷ мÓÆÂQala»ú·¿·þÎñÆ÷ Ïã¸Û»ú·¿·þÎñÆ÷ ·¨¹ú·þÎñÆ÷ ½ËÕµçÐÅ·þÎñÆ÷ ÃÀ¹úTB»ú·¿·þÎñÆ÷ ÈÕ±¾·þÎñÆ÷ ºÓ±±Íøͨ·þÎñÆ÷ ÏÃÃÅÈí¶þ·þÎñÆ÷ ̨Íå»ú·¿·þÎñÆ÷ º«¹ú»ú·¿·þÎñÆ÷ ÃÀ¹úST»ú·¿·þÎñÆ÷ ½Î÷µçÐÅ·þÎñÆ÷ ÆäËû»ú·¿·þÎñÆ÷ ·ÆÂɱö·þÎñÆ÷ ÈÕ±¾»ú·¿·þÎñÆ÷ ·ÆÂɱö»ú·¿·þÎñÆ÷
¹úÄÚ´ó´ø¿í
Mysql´æÈ¡sessionʵÀý
×÷Õß ØýÃû¼¼Êõ
À´Ô´ NET±à³Ì
ä¯ÀÀ
·¢²¼Ê±¼ä 2012-05-25
content
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn
ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!
SESSION["abc"]); print("<br>"); print(
Mysql´æÈ¡sessionʵÀý - ÁèÖڿƼ¼
¿ìËÙÒµÎñͨµÀ
++++Ñ¡ÔñͨµÀ++++
¹úÄÚ·þÎñÆ÷ ÏÃÃŵçÐÅ·þÎñÆ÷ ÉÇÍ·µçÐÅ·þÎñÆ÷ ÎÂÖݵçÐÅ·þÎñÆ÷ ÏÃÃÅÍøͨ·þÎñÆ÷ ÉÇÍ·Ë«Ïß·þÎñÆ÷ ÃÀ¹ú·þÎñÆ÷ Å·ÖÞ·þÎñÆ÷ ÃÀ¹úKT»ú·¿·þÎñÆ÷ ÃÀ¹úFDC»ú·¿·þÎñÆ÷ Ïã¸Û·þÎñÆ÷ мÓÆ·þÎñÆ÷ º«¹ú·þÎñÆ÷ ̨Íå·þÎñÆ÷ Ó¢¹ú·þÎñÆ÷ µÂ¹ú·þÎñÆ÷ мÓÆÂQala»ú·¿·þÎñÆ÷ Ïã¸Û»ú·¿·þÎñÆ÷ ·¨¹ú·þÎñÆ÷ ½ËÕµçÐÅ·þÎñÆ÷ ÃÀ¹úTB»ú·¿·þÎñÆ÷ ÈÕ±¾·þÎñÆ÷ ºÓ±±Íøͨ·þÎñÆ÷ ÏÃÃÅÈí¶þ·þÎñÆ÷ ̨Íå»ú·¿·þÎñÆ÷ º«¹ú»ú·¿·þÎñÆ÷ ÃÀ¹úST»ú·¿·þÎñÆ÷ ½Î÷µçÐÅ·þÎñÆ÷ ÆäËû»ú·¿·þÎñÆ÷ ·ÆÂɱö·þÎñÆ÷ ÈÕ±¾»ú·¿·þÎñÆ÷ ·ÆÂɱö»ú·¿·þÎñÆ÷
¹úÄÚ´ó´ø¿í
Mysql´æÈ¡sessionʵÀý
×÷Õß ØýÃû¼¼Êõ
À´Ô´ NET±à³Ì
ä¯ÀÀ
·¢²¼Ê±¼ä 2012-05-25
content
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn
ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!
SESSION["meto"]); echo "<br>". "<a href=\"get_session_test2.php\">click again</a>";
?>
get_session_test2.php
<?php //get_session_test2.php // test for using session include ("common/Common.config.php"); include ("include/session.inc.php");
session_start(); print(
Mysql´æÈ¡sessionʵÀý - ÁèÖڿƼ¼
¿ìËÙÒµÎñͨµÀ
++++Ñ¡ÔñͨµÀ++++
¹úÄÚ·þÎñÆ÷ ÏÃÃŵçÐÅ·þÎñÆ÷ ÉÇÍ·µçÐÅ·þÎñÆ÷ ÎÂÖݵçÐÅ·þÎñÆ÷ ÏÃÃÅÍøͨ·þÎñÆ÷ ÉÇÍ·Ë«Ïß·þÎñÆ÷ ÃÀ¹ú·þÎñÆ÷ Å·ÖÞ·þÎñÆ÷ ÃÀ¹úKT»ú·¿·þÎñÆ÷ ÃÀ¹úFDC»ú·¿·þÎñÆ÷ Ïã¸Û·þÎñÆ÷ мÓÆ·þÎñÆ÷ º«¹ú·þÎñÆ÷ ̨Íå·þÎñÆ÷ Ó¢¹ú·þÎñÆ÷ µÂ¹ú·þÎñÆ÷ мÓÆÂQala»ú·¿·þÎñÆ÷ Ïã¸Û»ú·¿·þÎñÆ÷ ·¨¹ú·þÎñÆ÷ ½ËÕµçÐÅ·þÎñÆ÷ ÃÀ¹úTB»ú·¿·þÎñÆ÷ ÈÕ±¾·þÎñÆ÷ ºÓ±±Íøͨ·þÎñÆ÷ ÏÃÃÅÈí¶þ·þÎñÆ÷ ̨Íå»ú·¿·þÎñÆ÷ º«¹ú»ú·¿·þÎñÆ÷ ÃÀ¹úST»ú·¿·þÎñÆ÷ ½Î÷µçÐÅ·þÎñÆ÷ ÆäËû»ú·¿·þÎñÆ÷ ·ÆÂɱö·þÎñÆ÷ ÈÕ±¾»ú·¿·þÎñÆ÷ ·ÆÂɱö»ú·¿·þÎñÆ÷
¹úÄÚ´ó´ø¿í
Mysql´æÈ¡sessionʵÀý
×÷Õß ØýÃû¼¼Êõ
À´Ô´ NET±à³Ì
ä¯ÀÀ
·¢²¼Ê±¼ä 2012-05-25
content
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn
ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»!
SESSION["c"]); ?>