Error while initializing session variable in

I am having error when initializing the session variable in my

Here is the value I am passing when I am calling my session function

CustomerIdentityHelper.setCustomerDetailsInSession("0", 0, 0, 0)

Here is the error complete message

Object variable or With block variable not set.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object variable or With block variable not set.

The error is coming on the following line of code
Line 26:         HttpContext.Current.Session("Customer")("Name") = Name


Public Shared Sub setCustomerDetailsInSession(ByVal Name As String, ByVal GoldMember As Boolean, ByVal PlatinumMember As Boolean, ByVal CustomerID As Long)
        HttpContext.Current.Session("Customer")("Name") = Name
        HttpContext.Current.Session("Customer")("G") = GoldMember
        HttpContext.Current.Session("Customer")("P") = PlatinumMember
        HttpContext.Current.Session("Customer")("CID") = CustomerID
        HttpContext.Current.Session("Customer")("Last") = DateTime.Now
    End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Make sure that the actual session variable Customer is initialized first, otherwise you are setting a property of an object which does not exist.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shieldguyAuthor Commented:
Thanks Mate
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.