PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, November 12, 2022

[FIXED] Where does Laravel store configuration for memcached session driver?

 November 12, 2022     laravel, laravel-4, memcached, php, session     No comments   

Issue

The Laravel docs specify that you can enable memcached as a session handler in app/config/session.php; however, it does not specify where memcached itself is configured (such as the servers to use).

I see that you can configure memcached in app/config/cache.php, but I don't know if that's used just for the Cache driver or for the session handler as well.


Solution

Yes, the config in app/config/cache.php for your cache drivers is used for session driver as well.

Take a look at vendor/laravel/framework/src/Illuminate/Session/SessionManager.php. The method that creates an instance of the Memcached session driver is this one

/**
 * Create an instance of the Memcached session driver.
 *
 * @return \Illuminate\Session\Store
 */
protected function createMemcachedDriver()
{
    return $this->createCacheBased('memcached');
}

That method is calling this other method in the same file

/**
 * Create an instance of a cache driven driver.
 *
 * @param  string  $driver
 * @return \Illuminate\Session\Store
 */
protected function createCacheBased($driver)
{
    return $this->buildSession($this->createCacheHandler($driver)); //$driver = 'memcached'
}

Which is calling this other method in the same file

/**
 * Create the cache based session handler instance.
 *
 * @param  string  $driver
 * @return \Illuminate\Session\CacheBasedSessionHandler
 */
protected function createCacheHandler($driver)
{
    $minutes = $this->app['config']['session.lifetime'];

    return new CacheBasedSessionHandler($this->app['cache']->driver($driver), $minutes);
}

There you can see: this->app['cache']->driver($driver) which is actually getting your cache driver from the IoC container



Answered By - Javi Stolz
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing