应用程序和会话变量之间的区别 [英] Difference between Application and session variable

查看:199
本文介绍了应用程序和会话变量之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序和会话变量之间的区别

Difference between Application and session variable

推荐答案

应用程序变量是整个应用程序对于所有用户仍然通用的变量……它们的值可以在任何用户都可以整个应用程序…并且它们只有在应用程序停止或可能被强行杀死时才会死亡……此类变量的理想示例是站点计数器……我们可以找出自访问特定站点以来有多少人访问了该站点通过应用程序变量实时运行,并在每次会话启动时递增该变量..



会话变量是整个应用程序但对于一个特定用户仍然通用的变量.它们也可以在整个应用程序中使用,但是每个用户都有一个副本...但是它们会在特定用户会话结束或可能被强行杀死时死亡...此类变量的理想示例是用户ID ...您可能想要在站点的每个页面上显示"Welcome Prabha",直到Prabha注销为止.因此,在会话开始时,将一个变量设置为"Welcome Meetu Choudhary",并在会话结束时将其杀死……
Application variables are the variables which remain common for the whole application for all the users… Their value can be used across the whole application by any user… And they die only when the application stops or probably when they are killed forcibly… The ideal example for these kind of variables are site counter… We can find out how many people accessed a particular site since the time it went live via application variables and incrementing the same on ever session start..

where as

Session variables are variables which remain common for the whole application but for one particular user. They also can be used across the whole application but each user will have a copy… But they die when a particular user session ends or probably when they are killed forcibly… The ideal example for this kind of variable are user id… You might want to show "Welcome Prabha " on every page of your site till Prabha logs off… So in session start you set a variable to "Welcome Meetu Choudhary" and kill it on end of session…


应用程序对象用于存储在整个应用程序中可见并在多个用户会话之间共享的数据.需要在应用程序的整个生命周期中保留的数据应存储在应用程序对象中.

在经典ASP中,应用程序对象用于存储连接字符串.这是存储不经常更改的数据的好地方.我们应该只在application_Onstart事件(global.asax)或application.lock事件中写入应用程序变量,以避免数据冲突.下面的代码示例给出了想法



会话对象:

会话对象用于按客户端存储状态特定的信息.它特定于特定用户.会话数据在用户会话期间持续存在,您可以通过不同方式将会话数据存储在Web服务器上.可以使用< session State>配置会话状态.应用程序的web.config文件中的"部分.
Application object is used to store data which is visible across entire application and shared across multiple user sessions. Data which needs to be persisted for entire life of application should be stored in application object.

In classic ASP, application object is used to store connection strings. It''s a great place to store data which changes infrequently. We should write to application variable only in application_Onstart event (global.asax) or application.lock event to avoid data conflicts. Below code sample gives idea



Session object:

Session object is used to store state specific information per client basis. It is specific to particular user. Session data persists for the duration of user session you can store session''s data on web server in different ways. Session state can be configured using the <session State> section in the application''s web.config file.


请参阅以下链接

应用程序与会话状态之间的差异. [ ^ ]

http://vishaljoshi.blogspot.com/2004/05/difference-between-application.html [^ ]
Refer the following links

Difference between Application and Session State.[^]

http://vishaljoshi.blogspot.com/2004/05/difference-between-application.html[^]


这篇关于应用程序和会话变量之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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