管理员必须重新加载页面才能查看管理员功能(有关Cookie位置的问题) [英] Admins having to reload page to see admin features (question about cookie location)

查看:58
本文介绍了管理员必须重新加载页面才能查看管理员功能(有关Cookie位置的问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个自定义cookie,并且已经重载了I​​principal类和所有这些好东西.我的Cookie可以正常工作,并且能够成功检索用户的角色,但是管理员必须在登录后才能重新加载默认页面,以查看仅管理员"按钮.他们访问了我网站上的新页面并返回默认页面后,该按钮就会出现.

I am creating a custom cookie and have overloaded the Iprincipal class and all that good stuff. My cookie works correctly and I am able to retrieve the roles of the users successfully, but the admins have to reload the default page after just logging in to see the admin only button. Once they visit a new page on my site and return to the default page, the button is there.

我在某处读到cookie是最后创建的,并且与对HTTP的响应有关. TBH,我是这方面的新手,并不完全了解它的工作原理,但是我看到了它如何影响我的程序.

I read somewhere that the cookie is created last and has something to do with a response to the HTTP. TBH, I am new to this stuff and don't understand exactly how that works, but I see how it effects my program.

我当前正在默认页面的页面加载中创建并植入cookie.我是否应该在登录页面的其他地方进行操作?我尝试过,但是同样的问题仍然存在.我想念什么吗?

I am currently creating and planting my cookie in the page load of my default page. Should I be doing it somewhere else, perhaps in the log-in page? I tried that, but the same issue still exists. Am I missing something?

感谢您的帮助,我很乐于澄清任何事情.

Thanks for the help and I would be more than happy to clarify anything.

推荐答案

,您可以尝试设置cookie并重定向.这是登录时的标准做法.重定向将导致新页面加载,在此期间您的cookie将被发送到服务器.

you might try setting the cookie and redirecting. this is somewhat standard practice during login. the redirect will cause a fresh page load during which your cookie will be sent to the server.

这篇关于管理员必须重新加载页面才能查看管理员功能(有关Cookie位置的问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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