可以将一个脚本解释在会话变量? [英] Can I store a Scripting Dictionary in a session variable?
问题描述
我有我的地方创建一个字典一个传统的ASP网站时,那本词典在会话变量像这样在用户登录,然后商店......
I have a classic ASP site where I create a dictionary when the user logs in and then stores that dictionary in a session variable like so...
dim objDict
set objDict = server.createobject("scripting.dictionary")
' processing here to fill dictionary
set session("user") = objDict
这一切工作正常,很正常,但是当我浏览到另一个页面,并尝试从这样存储的字典访问值...
That all works fine and dandy but when I navigate to another page and try to access a value from the stored dictionary like this...
session("user").item("id")
我得到以下错误...
I get the following error...
error '80020009'
谁能告诉我,如果我访问存储的字典错误?被存储在一个会话变量的字典对象坏/错误的事是什么?
Can anyone tell me if I'm accessing the stored dictionary incorrectly? Is storing the dictionary object in a session variable a bad/wrong thing to do?
感谢
推荐答案
你有没有在你的code尝试过做类似下面的东西时,你要访问它?
Have you tried in your code doing something like the following when you want to access it?
Dim objDict
Set objDict = session("user")
Response.Write objDict("id")
试一下,看看它是否工作。我不认为这将是必要的,但传统的ASP是不完全的最强大的语言。你想要做的应该是可行的,因为Session对象只存储对象。
Try that and see if it works. I wouldn't think this would be necessary but Classic ASP wasn't exactly the most robust language. What you want to do should be workable, since the Session object simply stores objects.
这篇关于可以将一个脚本解释在会话变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!