我可以将脚本字典存储在会话变量中吗? [英] 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")
我收到以下错误...
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?
谢谢
推荐答案
你有没有试过在你的代码中当你想访问它时做类似下面的事情?
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")
试试看它是否有效.我认为这不是必需的,但 Classic 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屋!