locked
Managing Session Variables RRS feed

  • Question

  • User1043796333 posted
    1. Are you allowed to save type of matrix data (m,n) in a Session variable. If so, how do you retrieve it. How do you use it later on?
    2. How can you manage your Session variables. Something like a UI to see the ones that are actives
    3. How do yo set expiration time to a a Session variable ?
    4. Is there a UI to see how they work, kind of debugg mode as to see if your logic's code is ok at runtime?
    Saturday, June 18, 2011 12:18 AM

Answers

  • User-1618234021 posted

    Hi

    See the answers in below:

    Are you allowed to save type of matrix data (m,n) in a Session variable. If so, how do you retrieve it. How do you use it later on?

    You can save any kind of data in session. But u should be careful about it since the size can grow. When you store something in session, it is converted into object. So when you retrieve it, you need to type cast it back. In your case, you can use a double dim array, store it in session, retrieve and cast it back and use it.

    How can you manage your Session variables. Something like a UI to see the ones that are actives
    You manage them through code. But if you enable tracing on page or app level, you can see them in the bottom half of the page while browsing it. You can enable it at the page tag like <%@Page Tracing="true" ..... %>
    How do yo set expiration time to a a Session variable ?
    Expiration time is for the full session. If that reached, the whole sessoin data will expire. Although you can remove a pecific object from session through code.
    Is there a UI to see how they work, kind of debugg mode as to see if your logic's code is ok at runtime?
    I have mentioned it in above point, using Tracing. Through debugging, you can also see them.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 18, 2011 3:45 AM
  • User-2139489267 posted

    In addition to what Adeel has said in response of your question, I suggest you to check out below link which will clear all your doubts regarding Session :

    http://msdn.microsoft.com/en-us/library/aa479041.aspx#aspnetsessionstate_topic5

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 18, 2011 4:38 AM
  • User-481631678 posted

    • Are you allowed to save type of matrix data (m,n) in a Session variable. If so, how do you retrieve it. How do you use it later on?

    You can store any object in Session but it needs to be serilizable.

    • How can you manage your Session variables. Something like a UI to see the ones that are actives

    There is no GUI provided to monitor Session variables. However you can access them through Session object.

    How do yo set expiration time to a a Session variable ?

    Session expiration is set in minutes. There are different ways through which you can set timeout for details see this:-

    http://zeeshanumardotnet.blogspot.com/2009/01/why-dot-net-sessions-are-cleared-before.html

    Is there a UI to see how they work, kind of debugg mode as to see if your logic's code is ok at runtime?

    There is no gui avaible for that as this might cause security issues.

    Also visit the following URL for details of session in ASP.Net, it will clarify lots of things with you and you can get better understanding of session:-

    http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 22, 2011 1:18 AM
  • User-578657687 posted

    Hi,

    • Are you allowed to save type of matrix data (m,n) in a Session variable. If so, how do you retrieve it. How do you use it later on?

    Of course you can, just lke this:

    Save the matrix to Session variable:

     int[,] matrix = new int[2,2];
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    matrix[i, j] = j;
                }
            }
            Session["matrix"] = matrix;

    Retrieve the Session variable:

     if (Session["matrix"] != null)
            {
                int[,] matrix = (int[,])Session["matrix"];
            }

    Use it:

    foreach (int i in matrix)
                {
                    //use the data(i) in  the matrix
                }

     

    • How can you manage your Session variables. Something like a UI to see the ones that are actives

    You just save the relevant data into the Session variable and then retrieve it from Session variable when you want to use it.

    There is nothing like an UI to see the Session variables. But you can monitor the Session variables by QuickWatch.

    How to use QuickWatch Dialog Box you can refer to this link:

    http://msdn.microsoft.com/en-us/library/cyzbs7s2(v=VS.100).aspx

    By the way, when you open the QuickWatch Dialog box, you can input the Sesion.Contents.Count to watch the count of Sesion variables and input the Session.Contents[index] to watch the value and type of Session variable. This link below will help you to watch relevant Session information:

    http://msdn.microsoft.com/en-us/library/ms524319.aspx

    • How do yo set expiration time to a a Session variable ?

    I suggest you to research this artcle about Session carefully, it wil help you to grasp the Session further:

    http://msdn.microsoft.com/en-us/library/ms178581.aspx

    • Is there a UI to see how they work, kind of debugg mode as to see if your logic's code is ok at runtime?

    Please refer to above answer, and you can watch you logic code by debugging step by step at runtime.

    Hope it helps.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 23, 2011 12:41 AM

All replies

  • User-1618234021 posted

    Hi

    See the answers in below:

    Are you allowed to save type of matrix data (m,n) in a Session variable. If so, how do you retrieve it. How do you use it later on?

    You can save any kind of data in session. But u should be careful about it since the size can grow. When you store something in session, it is converted into object. So when you retrieve it, you need to type cast it back. In your case, you can use a double dim array, store it in session, retrieve and cast it back and use it.

    How can you manage your Session variables. Something like a UI to see the ones that are actives
    You manage them through code. But if you enable tracing on page or app level, you can see them in the bottom half of the page while browsing it. You can enable it at the page tag like <%@Page Tracing="true" ..... %>
    How do yo set expiration time to a a Session variable ?
    Expiration time is for the full session. If that reached, the whole sessoin data will expire. Although you can remove a pecific object from session through code.
    Is there a UI to see how they work, kind of debugg mode as to see if your logic's code is ok at runtime?
    I have mentioned it in above point, using Tracing. Through debugging, you can also see them.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 18, 2011 3:45 AM
  • User-2139489267 posted

    In addition to what Adeel has said in response of your question, I suggest you to check out below link which will clear all your doubts regarding Session :

    http://msdn.microsoft.com/en-us/library/aa479041.aspx#aspnetsessionstate_topic5

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 18, 2011 4:38 AM
  • User-481631678 posted

    • Are you allowed to save type of matrix data (m,n) in a Session variable. If so, how do you retrieve it. How do you use it later on?

    You can store any object in Session but it needs to be serilizable.

    • How can you manage your Session variables. Something like a UI to see the ones that are actives

    There is no GUI provided to monitor Session variables. However you can access them through Session object.

    How do yo set expiration time to a a Session variable ?

    Session expiration is set in minutes. There are different ways through which you can set timeout for details see this:-

    http://zeeshanumardotnet.blogspot.com/2009/01/why-dot-net-sessions-are-cleared-before.html

    Is there a UI to see how they work, kind of debugg mode as to see if your logic's code is ok at runtime?

    There is no gui avaible for that as this might cause security issues.

    Also visit the following URL for details of session in ASP.Net, it will clarify lots of things with you and you can get better understanding of session:-

    http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 22, 2011 1:18 AM
  • User-578657687 posted

    Hi,

    • Are you allowed to save type of matrix data (m,n) in a Session variable. If so, how do you retrieve it. How do you use it later on?

    Of course you can, just lke this:

    Save the matrix to Session variable:

     int[,] matrix = new int[2,2];
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    matrix[i, j] = j;
                }
            }
            Session["matrix"] = matrix;

    Retrieve the Session variable:

     if (Session["matrix"] != null)
            {
                int[,] matrix = (int[,])Session["matrix"];
            }

    Use it:

    foreach (int i in matrix)
                {
                    //use the data(i) in  the matrix
                }

     

    • How can you manage your Session variables. Something like a UI to see the ones that are actives

    You just save the relevant data into the Session variable and then retrieve it from Session variable when you want to use it.

    There is nothing like an UI to see the Session variables. But you can monitor the Session variables by QuickWatch.

    How to use QuickWatch Dialog Box you can refer to this link:

    http://msdn.microsoft.com/en-us/library/cyzbs7s2(v=VS.100).aspx

    By the way, when you open the QuickWatch Dialog box, you can input the Sesion.Contents.Count to watch the count of Sesion variables and input the Session.Contents[index] to watch the value and type of Session variable. This link below will help you to watch relevant Session information:

    http://msdn.microsoft.com/en-us/library/ms524319.aspx

    • How do yo set expiration time to a a Session variable ?

    I suggest you to research this artcle about Session carefully, it wil help you to grasp the Session further:

    http://msdn.microsoft.com/en-us/library/ms178581.aspx

    • Is there a UI to see how they work, kind of debugg mode as to see if your logic's code is ok at runtime?

    Please refer to above answer, and you can watch you logic code by debugging step by step at runtime.

    Hope it helps.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 23, 2011 12:41 AM