Check http://laravel.io/forum/09-23-2015-session-not-persisting-on-shared-hosting-laravel-4217 and http://laravel.io/forum/11-29-2014-session-not-saving And http://laravel.io/forum/08-23-2015-laravel-51-session-not-persisting Don't start a session, that's done in Laravel already.
Session in 4.2 not persisting
I've been reading through all the threads on session issues and haven't found one quite like mine. I think perhaps I have a misundestanding of how the page loads work.
I have a page where I assign an array value to a session variable (tagList) in my getIndex() function:
public function getIndex()
{
$getTag = Request::query('tag');
$tagTable = DB::table('polaroids')
->join('polaroid_tag', 'polaroids.id', '=', 'polaroid_tag.polaroid_id')
->select(DB::raw('filename, polaroids.id as id, polaroid_tag.tag_id as tagid'))
->where('polaroid_tag.tag_id', '=', $getTag)
->orderByRaw('RAND()')->get();
$data = array_map(function($object){
return (array) $object;
}, $tagTable);
Session::put('tagList', $data);
On that page I have a jquery function which calls anther function from the same controller to swap out content on part of the page, that function is:
public function getDetails()
{
$getPos = Request::query('position');
$actualPos = Session::get('tagList');
$firstPos = $actualPos[$getPos]['id'];
$tagTable = DB::table('polaroids')
->join('polaroid_tag', 'polaroids.id', '=', 'polaroid_tag.polaroid_id')
->select(DB::raw('filename, polaroids.id as id, polaroid_tag.tag_id as tagid'))
->where('polaroids.id', '=', $firstPos)
->get();
$tagTable1 = DB::table('tags')
->join('polaroid_tag', 'tags.id', '=', 'polaroid_tag.tag_id')
->select(DB::raw('tag, tags.id as id'))
->where('polaroid_tag.polaroid_id', '=', $firstPos)
->orderByRaw('RAND()')->get();
$this->layout = View::make('tag.details')->with(compact('tagTable'))->with(compact('tagTable1'));
}
Here is the strange part, if I load my index page just once it will sometimes let me call the getDetails function one or twice before it starts giving me null responses and in testing it's because it shows my Session variable tagList as empty. However if load my index page once, then enter the full address /details?position=x, I can change x everytime and it still works, but if I go back to index and click on my next button it clears the session variable again. Any help or points in the right direction would be appreciated.
Thanks
Please or to participate in this conversation.