Laravel曲奇饼 [英] Laravel Cookies

查看:124
本文介绍了Laravel曲奇饼的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索和问问,但我找不到我在找什么,或任何类似的。



我正在寻找一种方法来传递某个用户的某些设置。
我在我的后端有一个菜单,用户可以缩小或保持宽。标准菜单宽。如果用户决定使用窄菜单,并转到另一个页面,菜单将重置为默认宽屏状态。我想和用户一起传递这个设置。



我知道我必须创建一个cookie。但还有什么?不知道。



!重要!我不是寻找直接的答案(这不会教我任何东西)我正在寻找如何做到这一点的建议,如果可能的网站附带包含一些解释。



像我说的,我知道如何做一个cookie,但我不知道如何附加到任何东西。

使用队列方法使用Cookie的最佳选项,因为Cookie会自动添加到响应中。



您可以为一个用户创建多个Cookie,但不能输入可选/不同的值。



如果用户将菜单更改为narrow,您应该保存Cookie的值为例如1,如果他想再次选择菜单,您可以删除该cookie或将其值设置为2.



加载页面,则应检查是否存在具有所选名称的Cookie,并且其值为1或不同。


I've been searching and asking around, but i can't find what i am looking for, or anything similair.

I am looking for a way to pass along certain settings for a user. I have a menu in my back-end which the user can narrow or keep wide. Standard the menu is wide. If a user devides to use the narrow menu, and goes to another page, the menu 'resets' to the default wide state. I'd like to pass along this 'setting' with the user.

I know i have to make a cookie. but what else?? no idea.

!IMPORTANT! I am NOT looking for straight answers (which wont teach me anything) I am looking for suggestions on how to do this and if possible a website attached containing some explanation.

Like i said, i know how to make a cookie, but i do not know how to attach it to whatever.

解决方案

The best option to use cookies using queue method because cookie will be automatically added to response.

You can create multiple cookies for one user but you cannot put optional / different values.

If user will change menu to narrow, you should save cookie with value for example 1, and if he wants menu to be wide again, you can remove the cookie or set it's value to 2.

Each time you load page, you should check if there's a cookie with selected name and if it's value is 1 or different.

这篇关于Laravel曲奇饼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆