如何使用用户会话ID查找用户是新用户还是当前用户 [英] how to find if user is new or current user using user session id

查看:111
本文介绍了如何使用用户会话ID查找用户是新用户还是当前用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以回答:


使用用户会话ID查找用户的C#代码是新用户还是当前用户.

Can anyone Answer:


C# code for to find user is new or current user using their user session id.

推荐答案

可以从WindowsPrincipal类中获取当前用户,如下所示:

Current user can be fetched from WindowsPrincipal class as:

AppDomain myDomain = Thread.GetDomain();

        myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
        WindowsPrincipal myPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;
        Console.WriteLine("{0} belongs to: ", myPrincipal.Identity.Name.ToString());


数据库中是否没有用户ID?为什么用SessionID标识用户?

这不是很好的编码方式.通过用户的用户ID而不是会话ID来识别用户.
您打开的浏览器编号没有会话ID的编号,那么如何识别新旧的?
Is there no userid present in database? Why you identify user with SessionID ?

This is not a good coding carry out. Identify user by their userid not by session id.
The no of browser you open that no of session ID get created then how can you identify which is new and old ?


这篇关于如何使用用户会话ID查找用户是新用户还是当前用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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