The obvious difference is that when stored in memcache(d)
data becomes available cross the system. Sessions store data per user, though, session_id()
could theoretically be used to share this data with more users.
However, in terms of performance, speed and memory usage - is there a difference?
PHP sessions are stored in the filesystem by default. You can modify this behaviour so that they are saved in a database, or in your case memcached.
So in terms of performance, memcached is generally faster than the filesystem. This obviously depends on your environment.
See session_set_save_handler
Apples and oranges. They achieve two entirely different things. Your real question is file storage vs. memcache. You could theoretically store session info in memcache instead of the file based storage. Then the performance of session would be identical to directly pushing a value to memcache.
All things being equal, memcache performs far better than file caching. In terms of memory, when you read the file to get the data (in this case the session file), it goes into memory anyhow, so its doesn't save any space. In fact if multiple requests happen to apache different worker process may need to read the same session file--each using their own chunk of memory until the worker process is reaped. Using memcache, this doesn't happen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With