# webapp user control

**URL:** <https://forum.xojo.com/t/webapp-user-control/11662>\
**Category:** Web\
**Created:** [October 15, 2013, 5:04pm UTC](https://forum.xojo.com/t/webapp-user-control/11662 "2013-10-15T17:04:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paulo\_Cezar](https://forum.xojo.com/letter_avatar_proxy/v4/letter/p/258eb7/32.png) [@Paulo\_Cezar](https://forum.xojo.com/u/Paulo_Cezar)\
**Post date:** [October 15, 2013, 5:04pm UTC](https://forum.xojo.com/t/webapp-user-control/11662/1 "2013-10-15T17:04:00Z")

</div>

Hello

I need to control which users are logged into my xojo webapp.  
I’m currently using a boolean field in mysql, but when the user close browser i can’t set the field to False.

there is a better way to do this?

On session.Close

```auto
  DIM DB As NEW MySQLCommunityServer

'....conection code here

 SESSION.UserID

DB.SQLExecute "UPDATE myUSERS SET ONLINE=0 WHERE myUSERS .IF=" + session.UserID 'HERE I RECEIVE AN NIL OBJECT ERROR
DB.close
```

---

<div class="post-metadata">

**Author:** ![damon\_pillinger](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/a88e57/32.png) [@damon\_pillinger](https://forum.xojo.com/u/damon_pillinger)\
**Post date:** [October 16, 2013, 12:29am UTC](https://forum.xojo.com/t/webapp-user-control/11662/2 "2013-10-16T00:29:39Z")

</div>

what is the “.IF” for. it wont cause the exception, just my SQL curiosity.

I use the same thing in my session.close event

have you got the session.UserID as a property in session? I am sure you have however it works for me so have to check.

Are you using XOJO? I am still using RealStudio, give it a try there you might have found a undocumented change/bug.

Have a great day  
Damon

---

<div class="post-metadata">

**Author:** ![David\_Cox](https://forum.xojo.com/user_avatar/forum.xojo.com/david_cox/32/227_2.png) [@David\_Cox](https://forum.xojo.com/u/David_Cox)\
**Post date:** [October 16, 2013, 10:19am UTC](https://forum.xojo.com/t/webapp-user-control/11662/3 "2013-10-16T10:19:36Z")

</div>

‘IF’ is a reserved command in MySQL, so if you want to use it as a field name you need to surround it with quotes:

```auto
DB.SQLExecute "UPDATE myUSERS SET ONLINE=0 WHERE `IF` = " + str(session.UserID)
```

Also you don’t need to use myUSERS.IF since you have already addressed it as the table name.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 4:53pm UTC](https://forum.xojo.com/t/webapp-user-control/11662/4 "2020-10-29T16:53:56Z")

</div>


