Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

get M_SECURITY_SESSION_COOKIE from CL_HTTP_SERVER

mrvila1
Explorer
0 Likes
1,150

Hello,

How can I get M_SECURITY_SESSION_COOKIE from class CL_HTTP_SERVER ?

I try:


call function 'HTTP_GET_CURRENT_SERVER_CB'

       importing

         server_cb = lo_http_server

       exceptions

          others    = 0.

but I can't get the attribute because is protected. How can I get it?

Thank you

1 ACCEPTED SOLUTION
Read only

custodio_deoliveira
Active Contributor
0 Likes
937

Hi Jordi,

You can create a subclass of CL_HTTP_SERVER and create a new public method to return the security session cookie:


CLASS lcl_my_http_server DEFINITION INHERITING FROM cl_http_server.

   PUBLIC SECTION.

     METHODS get_cookie RETURNING value(cookie) TYPE string.

ENDCLASS.

CLASS lcl_my_http_server IMPLEMENTATION.

   METHOD get_cookie .

     cookie = me->m_security_session_cookie.

   ENDMETHOD.

ENDCLASS.

DATA lo_http_server TYPE REF TO if_http_server.

DATA lo_my_http_server TYPE REF TO lcl_my_http_server.


   CALL FUNCTION 'HTTP_GET_CURRENT_SERVER_CB'

     IMPORTING

       server_cb      = lo_http_server

     EXCEPTIONS

       no_icf_session = 1

       OTHERS         = 2.

* cast from cl_http_server to your subclass

   lo_my_http_server ?= lo_http_server.

   DATA cookie TYPE string.

   cookie = lo_my_http_server->get_cookie( ).

   WRITE cookie.

Regards,

Custodio

4 REPLIES 4
Read only

custodio_deoliveira
Active Contributor
0 Likes
938

Hi Jordi,

You can create a subclass of CL_HTTP_SERVER and create a new public method to return the security session cookie:


CLASS lcl_my_http_server DEFINITION INHERITING FROM cl_http_server.

   PUBLIC SECTION.

     METHODS get_cookie RETURNING value(cookie) TYPE string.

ENDCLASS.

CLASS lcl_my_http_server IMPLEMENTATION.

   METHOD get_cookie .

     cookie = me->m_security_session_cookie.

   ENDMETHOD.

ENDCLASS.

DATA lo_http_server TYPE REF TO if_http_server.

DATA lo_my_http_server TYPE REF TO lcl_my_http_server.


   CALL FUNCTION 'HTTP_GET_CURRENT_SERVER_CB'

     IMPORTING

       server_cb      = lo_http_server

     EXCEPTIONS

       no_icf_session = 1

       OTHERS         = 2.

* cast from cl_http_server to your subclass

   lo_my_http_server ?= lo_http_server.

   DATA cookie TYPE string.

   cookie = lo_my_http_server->get_cookie( ).

   WRITE cookie.

Regards,

Custodio

Read only

0 Likes
937

Thank you very much for answer.

Im no sure why but im getting error when I do the cast

Read only

0 Likes
937

Hi Jordi.,

What error are you getting?

Read only

0 Likes
937

Or you can enhance the class CL_HTTP_SERVER and add a getter method.