Question: I have a large csv that I am hoping to import into Google Sheets. Each row has a column with "
=COUNTIF($A$2:$A, A2)<=1" (the A2 changes based on the row it is, incrementing each time) that when imported throws a "Formula Parse Error", but if I hand edit that formula at all or type it myself it will work fine.

Is there something I can do to allow that function to be imported?

Answer: 
There are lots of ways to implement this but here's one. I'd simplify the functions so that they each return a boolean. Move all the redirect logic, logout stuff into the calling code.

I am not sure the name of the session keys you use so I just used `hlbank_admin_user` and `staff_id`. I also made the assumption that if they're set, then the user is that role.

I renamed the functions to `isAdmin` and `isStaff`.

```
function isAdmin(): bool
{
    return isset($_SESSION['hlbank_admin_user']);
}

function isStaff(): bool
{
    return isset($_SESSION['staff_id']);
}

```

Then, in your calling code, you can check for either one.

```
if (!isAdmin() && !isStaff()) {
    // Not authorized >> redirect
}

```

Taking it one step further, you can create a single function to check if they are either an admin or staff.

```
function isPrivileged(): bool
{
    return isAdmin() || isStaff();
}

```

Then, in your calling code, you can check for that.

```
if (!isPrivileged()) {
    // Not authorized >> redirect
}

```

> 
> Thank you for your reply. But I'm confused by your answer. Actually,
> what I don't understand is why you didn't first declare the session
> variables $\_SESSION['hlbank\_admin\_user'] and $\_SESSION['staff\_id']
> returned in the isAdmin() functions and isStaff() because you just
> returned them with isset in each of those two functions ???
> 
> 
> But why return them knowing that they have not yet declared???
> 
> 
> 

Just to clear up any confusion, the way this normally works is during log-in, you set some session variables that you want to track in future requests. You don't need to redeclare them at all in the future. You can simply check for them, or read them.

Pseudocode for log in,

```
session_start()

if (username & password = true) {
    // These sessions values will persist for the entire session.
    // Just make sure to call `session_start()` on every page before trying to access them
    $_SESSION['isLoggedIn'] = true;
    $_SESSION['role'] = admin;
}

```

Then, when they try to access a restricted page you simply check if they are logged in and of a specific role.

Pseudocode to check access,

```
session_start()

$loggedIn = $_SESSION['isLoggedIn'] ?? false;
$role = $_SESSION['role'] ?? '';

if ($isLoggedIn === true && $role === 'admin') {
    // You are logged in and an admin
}

```
Thank you for your reply. But I'm confused by your answer. Actually, what I don't understand is why you didn't first declare the session variables `$_SESSION['hlbank_admin_user']` and `$_SESSION['staff_id']` returned in the `isAdmin()` functions and `isStaff()` because you just returned them with `isset` in each of those two functions ???

But why return them knowing that they have not yet declared???