Support the ongoing development of Laravel.io →
Session Cache
Last updated 2 years ago.
0

Let's start with the basics, can you show me how you are trying to create a session?

For example, are you using:

Session::put($key, $value);

?

Last updated 2 years ago.
0

@ayyobro, hi. Yes, I'm using default behaivor, here is my code:

Session::put([
	'user_id' => $user->user_id,
	'user_level' => $user->user_level,
	'user_name' => $user->user_name,

	'customer_id' => $customer->customer_id,
	'city_id' => $customer->city_id,
	'customer_name' => $customer->customer_name,
	'customer_distributor' => $customer->customer_distributor,

	'number_id' => $number->number_id,
	'number' => $number->number,
]);
Last updated 2 years ago.
0

Try it this way:

Session::put('test', array('key' => 'test1','key1' => 'test2','key2' => 'test3'));

I don't think session handles all the arguments you give. If that doesn't work, you could try looping through the data to store each item

Last updated 2 years ago.
0

hm, here is source of Laravel

/**
	 * Put a key / value pair or array of key / value pairs in the session.
	 *
	 * @param  string|array  $key
	 * @param  mixed|null  	 $value
	 * @return void
	 */
	public function put($key, $value = null)
	{
		if ( ! is_array($key)) $key = array($key => $value);

		foreach ($key as $arrayKey => $arrayValue)
		{
			$this->set($arrayKey, $arrayValue);
		}
	}
Last updated 2 years ago.
0

It seems my memory failed me looking at the source...

In this case it may be wise to store the data in an array variable first then try foreach:

foreach($myArray as $key => $val) 
{
     Session::put($key, $val);
}
Last updated 2 years ago.
0

Hi @paveleremin

I'm having the same problem here. Did you find a solution why it does not save? It works perfectly fine with "file" session drivers, but with memcached nothing is saved on Session::put.

thanks

Last updated 2 years ago.
0
Last updated 2 years ago.
0

@paveleremin

You forgot to do "Session::save();" after "Session::put('key', $variable);" Please try again and close the issue (https://github.com/laravel/framework/issues/6272) if your problem was solved!

paveleremin said:

I done:

  1. sudo apt-get install memcached
  2. sudo apt-get install php5-memcached
  3. sudo service apache2 restart

in my phpinfo() i saw Memcacmed so all is ok Cache::put('abcd',123) and Cache::get('abcd') - work fine but sessions not work.

Maybe some one can help me?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.