Question: I read [this](https://stackoverflow.com/questions/5842903/block-tridiagonal-matrix-python), but I wasn't able to create a (N^2 x N^2) - matrix **A** with (N x N) - *matrices* **I** on the lower and upper side-diagonal and **T** on the diagonal. I tried this

```
def prep_matrix(N):
    I_N = np.identity(N)
    NV = zeros(N*N - 1)
    # now I want NV[0]=NV[1]=...=NV[N-1]:=I_N

```

but I have no idea how to fill NV with my matrices. What can I do? I found a lot on how to create tridiagonal matrices with scalars, but not with matrix blocks.

Answer: 
Dirty, hacky, inefficient, solution (assumes use of forms authentication):

```
public void Global_BeginRequest(object sender, EventArgs e)
{
    if(
        Context.User != null && 
        !String.IsNullOrWhiteSpace(Context.User.Identity.Name) && 
        Context.Session != null && 
        Context.Session["IAMTRACKED"] == null
    )
    {
        Context.Session["IAMTRACKED"] = new object();
        Application.Lock();
        Application["UsersLoggedIn"] = Application["UsersLoggedIn"] + 1;
        Application.UnLock();
    }
}

```

At a high level, this works by, on every request, checking if the user is logged in and, if so, tags the user as logged in and increments the login. This assumes users cannot log out (if they can, you can add a similar test for users who are logged out and tracked).

This is a horrible way to solve your problem, but it's a working proto-type which demonstrates that your problem is solvable.

Note that this understates logins substantially after an application recycle; logins are much longer term than sessions.
That is the problem that you cannot do it using *Session[]* variables. You need to be using a database (or a central data source to store the total number of active users). For example, you can see in your application, when the application starts there is no `Application["UsersOnline"]` variable, you create it at the very instance. That is why, each time the application is started, the variable is initialized with a *new value*; always *1*.

You can create a separate table for your application, and inside it you can then create a column to contain *OnlineUsers* value. Which can be then incremented each time the app start event is triggered. 

```
public void Session_OnStart()
{
    Application.Lock();
    Application["UsersOnline"] = (int)Application["UsersOnline"] + 1;
    // At this position, execute an SQL command to update the value
    Application.UnLock();
}

```

Otherwise, for every user the session variable would have a new value, and you would not be able to accomplish this. Session variables were never designed for such purpose, you can access the variables, but you cannot rely on them for such a task. You can get more guidance about SQL commands in .NET framework, from MSDN's [SqlClient namespace library](https://msdn.microsoft.com/en-us/library/system.data.sqlclient%28v=vs.110%29.aspx).