Php writes file-type sessions to memcache

Source: Internet
Author: User
: This article describes how php writes file sessions to memcache. For more information about PHP tutorials, see.
 Get (self: session_key ($ PHPSESSID); if ($ val = false | $ val = null) {return false;} return $ val ;} public static function write ($ PHPSESSID, $ data) {$ method = $ data? 'Set': 'Replace '; return self: $ handler-> $ method (self: session_key ($ PHPSESSID), $ data, MEMCACHE_COMPRESSED, self :: $ lifetime);} public static function destroy ($ PHPSESSID) {return self ::$ handle-> delete (self: session_key ($ PHPSESSID ));} // memcache has a limited time and data is automatically destroyed. Therefore, you do not need to use the gc method public static function gc ($ lifetime) {return true;} // add a prefix to sessionID, avoid duplicate private static function session_key ($ PHPSESSID) {$ session_key = self: MS. $ PHPSESSID; return $ session_key; }}$ mem = new Memcache; $ mem-> connect ("localhost", 11211) or die ("cocould not connect"); MemSession :: start ($ mem );

The above describes how php writes file-type sessions to memcache, including some content. I hope my friends who are interested in PHP tutorials will be helpful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.