如果使用在多次用户登录不同的会话 [英] Use different session if user logs in multiple times

查看:144
本文介绍了如果使用在多次用户登录不同的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的ASP.NET项目,我们有code

On our ASP.NET project, we have the code

<sessionState mode="SQLServer" sqlConnectionString="data source=xxx;user id=xxx;password=xxx" cookieless="UseCookies" timeout="180" regenerateExpiredSessionId="false" />

这code必须保持不变,我们需要使用的cookies。但是,我们希望每次登录的时间有不同的会话。要做到这一点,我们正在考虑生成一个新的GUID每次登录和使用时间,作为会议的一部分。所以,与其会话[用户],它会像会话[用户+ GUID。用户只会有一个会话,但如果我们用不同的GUID每个登录,那么我们应该能够有区分会话。我们正在运行到哪里出了问题我们存储GUID?我试过HTTP头,ViewState的,但是,如果我们做一个完全刷新,那些被全歼。有谁知道,我们可以存储唯一的GUID我们生成时,在用户登录?

This code must remain unchanged, we need to be using cookies. However, we want to have a different session every time they login. To do this, we are thinking of generating a new GUID every time they log in and use that as part of the session. So, instead of Session["User"], it'll be something like Session["User"+GUID]. That user is only going to have one session, but if we use different GUID for each login, then we should be able to have differentiate the session. The problem we are running into where do we store that GUID? I've tried HTTP Headers, ViewState, however, if we do a full refresh, those are wiped out. Does anyone know where we can store the unique GUID we generate when the user logs in?

请看看评论,如果你想知道我们实际上是试图做。我知道这是在做它的一个可怕的方式,但应用程序是真的老了,这可能是没有做一个大重写的唯一途径。

Please look at the comment if you want to know what we are actually trying to do. I know this is a horrible way of doing it, but the app is really old and this may be the only way without doing a big re-write.

推荐答案

我已经实现了在ASP.NET应用程序的WebForms类似的东西。它会为给定用户不同的会议,当他运行在浏览器中的多个选项卡中的应用。我使用的方法:我在登录验证函数创建一个会话ID,那么它在查询字符串参数被转移从一个网页到另一个,并存储在当前形式的ViewState

I have implemented something like that in an ASP.NET WebForms application. It creates different sessions for a given user when he runs the application in multiple tabs of a browser. The method I use: I create a SessionID in the login validation function, then it is transfered in a QueryString parameter from one page to the other, and stored in the ViewState of the current form.

这篇关于如果使用在多次用户登录不同的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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