# multi user session 1.7,0 accessing session inside update function

**URL:** <https://support.prodi.gy/t/multi-user-session-1-7-0-accessing-session-inside-update-function/1231>\
**Category:** Uncategorized\
**Tags:** enhancement, usage\
**Created:** [February 21, 2019, 4:39am UTC](https://support.prodi.gy/t/multi-user-session-1-7-0-accessing-session-inside-update-function/1231 "2019-02-21T04:39:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kabir](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/kabir/32/1300_2.png) [@kabir](https://support.prodi.gy/u/kabir)\
**Post date:** [February 21, 2019, 4:39am UTC](https://support.prodi.gy/t/multi-user-session-1-7-0-accessing-session-inside-update-function/1231/1 "2019-02-21T04:39:09Z")

</div>

I’m loading and writing data to a custom database and inside the update function I want to access the current user session

e.g.  
For `http://localhost:8080?session=kabir`  
I want to add

```python
{
   "annotator": "kabir"
}

```

to each example passed to the update callback.

Is there a way to do this easily?  
Using `get_db().sessions` only returns the default date session (2019-02-21\_04-30-03)

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [February 21, 2019, 9:05am UTC](https://support.prodi.gy/t/multi-user-session-1-7-0-accessing-session-inside-update-function/1231/2 "2019-02-21T09:05:09Z")

</div>

> [@kabir](#):
>
> Is there a way to do this easily?

I need to think about this some more, but I don't think there is at the moment, no. I definitely understand what you're trying to do here, though. Maybe it'd make sense to have a feature like this built-in. If not by default, there could be a setting like `"add_session_id_to_task"` (or something like that).

One quick note about the `update` callback btw: The `update` callback only receives a copy of the example, so you can't modify examples and have the changes reflected in the database. The reason for that is to ensure that what ends up in the database is _exactly_ what the annotator saw and worked on. Otherwise, you only need one tiny bug in your code to potentially destroy all your data – and you might not even find out until much later.

If you want to play around with this in the meantime, you could have a look at the `give_answers` endpoint in `prodigy/app.py`. To find the location of your Prodigy installation, you can run the following:

```bash
python -c "import prodigy; print(prodigy. __file__ )"

```

If a custom named session ID is set, `give_answers` will receive it as the `session_id` argument. So you _could_ do the following:

```python
for answer in answers:
    answer["session_id"] = session_id

```

Note that this will add the full session ID, like `your_dataset-kabir`, so you'd have to split the string if you only want the session identifier.

---

<div class="post-metadata">

**Author:** ![kabir](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/kabir/32/1300_2.png) [@kabir](https://support.prodi.gy/u/kabir)\
**Post date:** [February 21, 2019, 10:01pm UTC](https://support.prodi.gy/t/multi-user-session-1-7-0-accessing-session-inside-update-function/1231/3 "2019-02-21T22:01:24Z")

</div>

> [@ines](#):
>
> One quick note about the `update` callback btw: The `update` callback only receives a copy of the example, so you can't modify examples and have the changes reflected in the database. The reason for that is to ensure that what ends up in the database is _exactly_ what the annotator saw and worked on. Otherwise, you only need one tiny bug in your code to potentially destroy all your data – and you might not even find out until much later.

Yeah that's what I meant in my post. Totally makes sense and it's exactly the behavior I want.

I'll take a look at the `give_answers` endpoint. I'm not sure this really warrants its own feature since it seems like a real edge case but would be a nice-to-have.
