# How can a CGI get the username of the session?

**URL:** <https://forums.digi.com/t/how-can-a-cgi-get-the-username-of-the-session/10847>\
**Category:** Rabbit\
**Created:** [September 17, 2010, 1:12am UTC](https://forums.digi.com/t/how-can-a-cgi-get-the-username-of-the-session/10847 "2010-09-17T01:12:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![larrygl](https://avatars.discourse-cdn.com/v4/letter/l/bc8723/32.png) [@larrygl](https://forums.digi.com/u/larrygl)\
**Post date:** [September 17, 2010, 1:12am UTC](https://forums.digi.com/t/how-can-a-cgi-get-the-username-of-the-session/10847/1 "2010-09-17T01:12:29Z")

</div>

I have a CGI that needs to change its content based on what user is logged in. I am using DC 9.50 and rabbitweb on an RCM3315. I have traced into HTTP.LIB and found that authenticated userid is saved to state-\>context.userid.

But in my CGI, FileListCGI(HttpState \* s), s-\>context.userid is -1.

How can I get to the state structure where my authentication was saved, from the application-level CGI callback?

Thanks,  
Larry

---

<div class="post-metadata">

**Author:** ![larrygl](https://avatars.discourse-cdn.com/v4/letter/l/bc8723/32.png) [@larrygl](https://forums.digi.com/u/larrygl)\
**Post date:** [September 21, 2010, 9:13pm UTC](https://forums.digi.com/t/how-can-a-cgi-get-the-username-of-the-session/10847/2 "2010-09-21T21:13:12Z")

</div>

The call above should have worked. Debugging into HTTP.LIB, I found that the address that the user id is saved to is the same as the address I am checking in the callback. Something stomps it between authentication and callback.

I added a global int LastAuthUser to HTTP.LIB. You have to put it between the BeginHeader and EndHeader comment lines to make it visible outside the LIB.

Larry  
[www.GlueLogix.com](http://www.GlueLogix.com)
