简体   繁体   English

使相同的cookie在不同的Azure实例之间可读

[英]Make the same cookie readable between different Azure instances

On my website, there is a registration form. 在我的网站上,有一张注册表。 After having filled this in, the user gets redirected to Azure ACS in order to log in. After having logged in, the user gets redirected back to my website and is to be registered and logged in. 填写完之后,用户将重定向到Azure ACS以便登录。登录后,用户将重定向回到我的网站并进行注册和登录。

The registration form's information is saved in a cookie before the user is transferred to ACS, in order to be read when the user returns. 在将用户转移到ACS之前,将注册表单的信息保存在cookie中,以便在用户返回时进行读取。 Azure might suddenly change server instance for my webrole, and it seems the cookie cannot be read in those cases. Azure可能会突然为我的webrole更改服务器实例,并且在这种情况下似乎无法读取cookie。 Since the user gets transferred to ACS, it seems I cannot store the registration information in a session. 由于用户已转移到ACS,看来我无法在会话中存储注册信息。 I think I need to use cookies. 我想我需要使用Cookie。 Is there any way to make the same cookie readable between different Azure instances? 有什么方法可以使同一Cookie在不同的Azure实例之间可读? Or is there a better solution? 还是有更好的解决方案? Thanks for any help. 谢谢你的帮助。

As with any website that's on more than one server, you'll need to store session data in a database or other storage that's available across all instances. 与在多台服务器上的任何网站一样,您需要将会话数据存储在可用于所有实例的数据库或其他存储中。

Here's a blog post that details the options you have available in Azure Web Roles: http://blogs.msdn.com/b/cie/archive/2013/05/17/session-state-management-in-windows-azure-web-roles.aspx 这是一篇博客文章,详细介绍了Azure Web角色中可用的选项: http : //blogs.msdn.com/b/cie/archive/2013/05/17/session-state-management-in-windows-azure-网络roles.aspx

That being said, I don't know why a cookie wouldn't work between Azure instances. 话虽这么说,但我不知道为什么Cookie在Azure实例之间不起作用。 What are you doing to set/read the cookie? 您正在做什么设置/读取cookie?

Firstly, you can use session variables in Windows Azure Cloud Services like any other web application . 首先, 您可以像其他任何Web应用程序一样在Windows Azure云服务中使用会话变量 What you can't do is use In-Proc session state management . 您不能使用In-Proc会话状态管理 As @CoderDennis mentioned, you would need to store session state at a place where it is accessible to all the instances. 如@CoderDennis所述,您需要将会话状态存储在所有实例均可访问的位置。

My recommendation would be to use Windows Azure Role Based Cache and use that session state provider for session state management. 我的建议是使用Windows Azure Role Based Cache并使用该会话状态提供程序进行会话状态管理。 You may find this link helpful to do that: http://www.windowsazure.com/en-us/manage/services/cache/net/how-to-in-role-cache/#store-session . 您可能会发现此链接对执行此操作很有帮助: http : //www.windowsazure.com/en-us/manage/services/cache/net/how-to-in-role-cache/#store-session

Coming to cookies based solution, that would work as well. 来到基于cookie的解决方案,那也可以。 Remember that all your instances sit behind a load balancer, there's nothing special you would need to do read cookies between Azure instances as all of the instances will share same domain name. 请记住,您的所有实例都位于负载平衡器的后面,在所有Azure实例之间读取cookie并不需要做任何特殊操作,因为所有实例将共享相同的域名。

For shared storage, you could store the data in an azure table instead of a database. 对于共享存储,您可以将数据存储在azure表中,而不是数据库中。 Depending on your requirements, you may not need a fully fledged DB to do this. 根据您的要求,您可能不需要完整的数据库来执行此操作。 Azure tables are reliable, scale out well and are very simple to use and manage. Azure表是可靠的,可以很好地扩展,并且使用和管理非常简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何隔离同一组件的不同实例之间的js变量? - How to isolate js variables between different instances of the same component? 在不同端口之间共享Cookie - Sharing Cookie between different ports 如果两个不同的类具有相同的属性,如何自动映射两个不同类的实例之间的值? - How to automatically map the values between instances of two different classes if both have same properties? 如何使不同子类的实例具有其共同父类 class 的相同实例? - How do I make instances of different child classes have the same instance of their common parent class? WPF中同一用户控件的不同实例中的不同值 - Different values in different instances of the same usercontrol in WPF 在同一应用程序的多个实例之间传递数据 - Passing data between multiple instances of same application 相同应用程序的2个实例之间的静态方法 - Static methods between 2 instances of the same application 在同一程序的多个实例之间同步 - Syncing between multiple instances of the same program 在同一程序的两个实例之间发送数据 - Send data between two instances of the same program 区分流程的不同运行实例 - Differentiating between different running instances of a process
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM