locked
where to keep unique info RRS feed

  • Question

  • User1610800555 posted

    hi

    i am storing user information in session variable but the session variables shared by browser windows on same machine ( 2 chrome browser window). so i want to add a unique info with each session variable name

    Session("UserID" & UniqueId) = "23445"

    my question is where to keep this UniqueId to share among pages on same browser window?

    Thursday, February 26, 2015 1:35 AM

All replies

  • User2008642861 posted

    Hi sivakl_2001,

    As I know, it is another issue about how to pass value from a page to others' pages.

    so i want to add a unique info with each session variable name

    Session("UserID" & UniqueId) = "23445"

    What's your meaning about above? As far as I am concerned, the Session's name your have defined, it is unique.

    string UniqueId = Session["UniqueId"].ToString();
                Session["UserID" + UniqueId] = "23445";

    I am not sure above code is what you want. If I understand you incorrectly, could you please provide me more details about your requirement.

    Best regards,

    Archer

    Friday, February 27, 2015 2:42 AM
  • User1610800555 posted

    string UniqueId = Session["UniqueId"].ToString(); Session["UserID" + UniqueId] = "23445";

    but the Session["UniqueId"] is give same value not unique in same browser windows on same machine

    Friday, February 27, 2015 11:56 PM
  • User475983607 posted

    sivakl_2001

    hi

    i am storing user information in session variable but the session variables shared by browser windows on same machine ( 2 chrome browser window). so i want to add a unique info with each session variable name

    Session("UserID" & UniqueId) = "23445"

    my question is where to keep this UniqueId to share among pages on same browser window?

    You're question does not make sense as session is already unique by browser instance.  

    I think there may be holes in your understanding of session which is causing confusion. Once session is used,  the ASP framework sends a special cookie to the client.  This "Session Cookie" contains a unique key that identifies the user's unique session space on the server. BTW, you can view the "Session Cookie" by opening the developer tools (F12).  Each time the user makes a request, the "Session Cookie" travels to the server.  The ASP framework uses the session cookie to find the user's session space and retrieve any persisted values for that user.

    It is easy to verify session uniqueness by viewing the Session ID created from different browser instances.  However, that does not mean opening a new tab!  Opening a new tab is not the same as a new instance. 

    Learn about Session

    https://msdn.microsoft.com/en-us/library/ms972338.aspx

    Saturday, February 28, 2015 10:08 AM
  • User1610800555 posted

    You're question does not make sense as session is already unique by browser instance.  

    I think there may be holes in your understanding of session which is causing confusion

    really?

    Session will be shared among browser windows on same machine. that's why i want to make the session unique among browser windows by unique id. i think this is the only one way

    login.aspx

    Session("UserId" & UniqueId) = "23455"

    Response.Redirect("Default.aspx?UID="& UniqueId)

    Default.aspx

    Dim UniqueId as String = Request.QueryString("UID")

    Dim UserId as String = Session("UserId" & UniqueId)

    Saturday, February 28, 2015 11:24 PM
  • User475983607 posted

    really?

    Session will be shared among browser windows on same machine. that's why i want to make the session unique among browser windows by unique id. i think this is the only one way

    Yes, and purely by definition this is not possible. The best you can do is make it difficult to open a new tab.  For example, disable right clicking.

    login.aspx
    
    Session("UserId" & UniqueId) = "23455"
    
    Response.Redirect("Default.aspx?UID="& UniqueId)
    
    Default.aspx
    
    Dim UniqueId as String = Request.QueryString("UID")
    
    Dim UserId as String = Session("UserId" & UniqueId)

    The above will not work 100%.  1) user can create bookmarks.  2) Every link in the application must be updated.   The preceding approach adds another level of dependency in an already session dependent application.  Ultimately affecting extensibility. 

    I'm going out on a limb and guessing opening a new browser tab causes unwanted data issues in the application.  If that's the case, you should fix the design issue rather than adding complexity.

    Sunday, March 1, 2015 9:27 AM
  • User753101303 posted

    Hi,

    If you need further help it could be helpfull to understand what is the "scope" you want for this id and to explain what is the problem you are trying to prevent.

    Wednesday, March 4, 2015 11:35 AM