0

First of all, I got a question

in .asp page

Class clsTesting

Function hash_call ( methodName,nvpStr )

.....
Set SESSION("nvpReqArray")= deformatNVP( nvpStrComplete )
.....

End Function

end class

When I perform call to this function, once reach the Set SESSION("nv line it say error:

Microsoft VBScript runtime (0x800A01A8)
Object required: 'session'

How do I define the variable? I tried dim SESSION, dim SESSION("nv... not working!

Is it run it outside of class, then no need to declare those variables?

1
  • I found one of the reason already. Its due to <%option explicit%> Anyone can give me a solid idea on why use option explicit, what are the benefits to use option explicit? I found that by using option explicit, I have to take care of all the variable declaration.... even object, I need to create, sometimes just not sure how to create certain special object, and waste me quite some time..... Isn't it loosely type like php declaration is better and easier? Guys, any comment? Commented Jul 16, 2009 at 10:05

1 Answer 1

2

Try:

Session["nvpReqArray"] = deformatNVP( nvpStrComplete )

You don't need to define a session variable, it's one of the built in objects of asp3.

Edit:

Option explicit is a directive which forces you to declare all variables. (As you've noticed.).
This aids programming, and helps ensure variables are used consistently.
I would recommend you using it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.