[Klone-users] Hook function and global variables

thomas fossati tho at koanlogic.com
Tue Jan 27 08:32:30 EST 2009


Hi Mickael,

On Jan 27, 2009, at 11:44 AM, Mickael Auger wrote:
> Hi,
>
> I use the "session" global variable (with "session_set() function)  
> to memorize information of connected user and I use the  
> "session_get()" function to read this information.
> I use the "hook" functions (hooks_setup, ...) but I wish to use the  
> "session" global variable in my definition of "hook_request()" to  
> trace the connected user's name who make the request.
>
> However I have this compilation error :
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> fctscommunes.c: In function `server_request':
> fctscommunes.c:23: `session' undeclared (first use in this function)
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
> Have you a solution, please (specifique include ...) ?

I've never tried this out but take a look at the following:

int server_request (request_t *rq, response_t *rs)
{
     http_t *http;
     session_opt_t *so;
     session_t *ss = NULL;

     dbg_return_if (rq == NULL, ~0);
     dbg_return_if (rs == NULL, ~0);

     /* create a session object from HTTP request */
     dbg_err_if ((http = request_get_http(rq)) == NULL);
     dbg_err_if ((so = http_get_session_opt(http)) == NULL);
     dbg_err_if (session_create(so, rq, rs, &ss));

     /* ... do something with rq, rs and ss ... */

     session_free(ss);

     return 0;
err:
     if (ss)
         session_free(ss);
     return ~0;
}

ciao, t.




More information about the klone-users mailing list