asp.net创建新的Session [英] asp.net Create new Session

查看:127
本文介绍了asp.net创建新的Session的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,使用者登入,然后与相关的用户数据访问的第二页。到目前为止,我已完成了工作,当用户登录有用户ID和用户名被保存到一个会话。问题是,当多个用户登录,它们将覆盖每个人的会话。

I have a website that a user signs into and then access a second page with data relevant to that user. So far I have got it working that when the user logs there userID and username is saved into a session. The problem is when multiple users sign in they overwrite each others session.

string testusername = Session["UserName"] + ""; //Session data for username and user ID
string testuserid = Session["UserID"] + "";

基本上,我想弄清楚的是如何为每个用户创建一个新的会话,或者,如果有,让我保存的用户名和用户ID以这样的方式,只有网站将知道是谁送的另一种方法是什么信息。

Basically what I am trying to figure out is how to create a new session for each user or if there is another method that would allow me store the username and userID in such a way that only the website will know who to send what information to.

推荐答案

所以想通了我的问题,这是我的错误。我没有告诉网站,目前正在显示的信息有什么做的会话。最后,我加入了类似下面的code的东西。

So figured out my problem, it was my mistake. I was not telling the website that the information that was being displayed had anything to do with the session. In the end I added something similar to the code below.

sqlCompleted.SelectCommand = Session["SessionsqlCompleted"] + "";

这再制成保存每个会话所以现在显示的数据是相关的每个会话的SQL。我很抱歉我之后,我曾想过这个完全错误的方式几天实现一次。

This then made the sql saved with each session so now the data that is displayed is relevant to each session. I apologize I realised once after a few days that I had thought about this completely the wrong way.

感谢,虽然所有帮助。

这篇关于asp.net创建新的Session的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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