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.
I think the session items are client sided.
You can create a query to count the open connections (hence you're working with a MySQL database.)
Another option is to use external software (I use the tawk.to helpchat, which shows the amount of users visiting a page in realtime).
You could maybe use that, making the supportchat invisible, and only putting it on paging which are accesible for loggedin users.

OR

Execute an update query which adds/substracts from a column in your database (using the onStart and OnEnd hooks).