By defualt PHP stores the session in file and these setting are defined in php.ini file. It would have two settings for saving the sessions in file.
If you are not sure what is the session save path then you should read this post about Session Save Path in PHP.
Be default it will have below lines in your php.ini file.
[cc lang=”apache”]
session.save_handler = files
session.save_path = “/session save path/”
[/cc]
To save your sessions using memcache you need to change your php.ini lines to below lines. To save your session using memcache you will need below details to get it done.
- Memcache Server
- Memcache Port
After getting these details you will need to comment above lines and need to place below lines.
[cc lang=”apache”]
session.save_handler = memcache
session.save_path=”tcp://server:port?persistent=1&weight=1&timeout=1″
[/cc]
After making these changes you will need to restart your web server. Here what we are instructing php to set session handler to memcache and in next line we are defining the save path for session.
You might be surprized Why would you save your PHP sessions in memcache? If you are curious to know what would be the reason then subscribe to our RSS Feed, You will be notified by the email for this answer.
[…] By defualt PHP stores the session in file and these setting are defined in php.ini file. PHP Read the original post on DZone… […]
Hi I have done this just to test but now phpmyadmin does not work is there a way to make them work i am a newbie….
Hi I have done this just to test but now phpmyadmin does not work is there a way to make them work i am a newbie….
Thank for post and OK. We can use memcache for storing sessions. Is memcache right for this chose ? Because, memcache just a cache system. Our session datas will be secured ?
Hi Selim,
Its a best option if you have multi application server. That is what I am suppose to write on upcoming days. Stay tunes for updates :)
Memcached’s problem specifically is that it is cache. It can drop old data (your session), when new data come in.
I have recommended people to try scache and get rid of using $_SESSION altogether. Scache has built in sessionhandler, but it encourages hard to use its own API instead and split session data to small fragments that are accessed separately.
It is also suitable for multi front end constructions and has many other fancy features.
Thank for post and OK. We can use memcache for storing sessions. Is memcache right for this chose ? Because, memcache just a cache system. Our session datas will be secured ?
[…] Avinash on Jan 26, 2012 in Caching, PHP | 0 comments Few Days back I have posted about storing the PHP Session in MemCache Server. Before this article I have also written about setting up PHP Session Path. With this article you […]
thanks for your tips and it’s a nice blog!!!
thanks for your tips and it’s a nice blog!!!
[…] Memcached is very useful for increasing the site performance. There are several ways in which you can increase the site performance with MemcacheD, I have already written one of the way on this site which you can find at Save Session in Memcached. […]