Ad
How To Use Cookies For Getting Multiple Value On Laravel 5.6?
Actually, I am new on cookies (haven't work on it)
what I am trying to do is Whenever clients visit my site and read an article get the id of that read article (without login). whenever clients came back on the same site form the same device which he/she
has visited Then hide article which has been already read show only not read articles.
I have to try to create cookies like this
Cookie::queue(cookie('key', 'value', $minute = 10));
request()->cookie('key');
but whenever I update value it only get only the latest value. so Is it possible to do it by using cookies? or is there any alternative that which I can use for making this possible?
Ad
Answer
Yes, it is possible.Instead of using the simple value you have to use an array of ids.
Example:-
Cookie::queue(Cookie::make('seen_posts', json_encode([1,2]), $minutes));
Updating cookies
$seen_posts = json_decode($request->cookie('seen_posts'),true);
$seen_posts[] = 3;
Cookie::queue(Cookie::make('seen_posts', json_encode($seen_posts), $minutes));
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad