Memcached methods and security issues for saving sesion data

Source: Internet
Author: User
Tags session id sesion

As we all know, the traditional session data is stored in the file, so that, to a certain extent, reduce the speed.

Before we implement the problem, the php.ini should be configured as follows:

Session.save_handler = memcache //Specify to save data using memcached

Session.save_path = "tcp://127.0.0.1:11211" //connection to specify session data

Sometimes you can also use Ini_set ("key", "key value") to set the php.ini operation configuration.

When we want to take out, the key should be the session ID, not the name.

<?phpsession_start (); $_session[' name ']= "xuning"; $name =$_session[' name '];echo $name. ' <br/> '; echo session_id ();? >

Similarly, it can be used to save object data.


While it is said that Memcached has a great advantage in terms of speed, it is absolutely not recommended to save important information because the data is completely lost after shutting down the service.

Furthermore, data is not bound to any user and can be extracted directly from the key name. The session must be assigned to the user.

It is forbidden to use memcached in public network, if used, to join the firewall.



Memcached methods and security issues for saving sesion data

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.