2015 Jan 14 4:26 PM
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
2015 Jan 14 10:44 PM
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
2015 Jan 14 10:44 PM
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
2015 Jan 15 4:13 PM
Thank you very much for answer.
Im no sure why but im getting error when I do the cast
2015 Jan 15 9:34 PM
2015 Jan 16 6:15 AM
Or you can enhance the class CL_HTTP_SERVER and add a getter method.