Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7503905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:23:22+00:00 2026-05-29T21:23:22+00:00

I’m quite new to vb.net as I’m much more of a PHP developer but

  • 0

I’m quite new to vb.net as I’m much more of a PHP developer but anyway. I’ve built a web application but my users seem to be sharing the same session which I do not want and can’t understand why. I access the object which I store all session information in from a global property in a module, could this be the reason?

The code is as follows:

Module SiteWide
    Private mUserSession As New MyLib.User.UserSession
    Public Property gUserSession() As MyLib.User.UserSession
        Get
            If Not HttpContext.Current Is Nothing AndAlso Not HttpContext.Current.Session Is Nothing Then
                If Not HttpContext.Current.Session("user") Is Nothing Then
                    mUserSession = HttpContext.Current.Session("user")
                End If
            End If

            Return mUserSession 
        End Get
        Set(ByVal value As MyLib.User.UserSession)
            mUserSession = value

            If Not HttpContext.Current Is Nothing AndAlso Not HttpContext.Current.Session Is Nothing Then
                HttpContext.Current.Session("user") = value
            End If
        End Set
    End Property
End Module
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:23:24+00:00Added an answer on May 29, 2026 at 9:23 pm

    Why are you using a static class(Module) as repository for your Session objects? Static means application wide. mUserSession is also static implicitely, therefore all users share the same Session. Actually the lines

    mUserSession = value 
    

    and

    mUserSession = HttpContext.Current.Session("user")
    

    in the getter/setter are overwriting it for all users.

    You could wrap the Session object in your own class just for simplification:

    For example:

    Public Class MySession
        ' private constructor
        Private Sub New()
        End Sub
    
        ' Gets the current session.
        Public Shared ReadOnly Property Current() As MySession
            Get
                Dim session As MySession = DirectCast(HttpContext.Current.Session("__MySession__"), MySession)
                If session Is Nothing Then
                    session = New MySession()
                    HttpContext.Current.Session("__MySession__") = session
                End If
                Return session
            End Get
        End Property
    
        ' **** add your session properties here, e.g like this:
        Public Property MyID() As Guid
            Get
                Return m_ID
            End Get
            Set(value As Guid)
                m_ID = value
            End Set
        End Property
        Private m_ID As Guid
    
        Public Property MyDate() As DateTime
            Get
                Return m_MyDate
            End Get
            Set(value As DateTime)
                m_MyDate = Value
            End Set
        End Property
        Private m_MyDate As DateTime
    
    End Class
    

    Note: The Current-property is also shared/static, but the difference is that i’m returning HttpContext.Current.Session whereas you are returning a single/shared instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.