on 02-09-2005 3:10 PM
Hi
I am trying to understand the use of server-side cookies in a non mvc base application with single page. I have an auto attribute in page called 'count' which I am increamenting on OnInputProcessing().
In OnRequest() I am getting the server-side cookie using 'CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>GET_SERVER_COOKIE' and take value of count from that and display that on my layout.
In OnManipulation() I am setting the value of count back to the cookie using ' CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>SET_SERVER_COOKIE'
My problem is the value of count set to '0' when I am accessing it. then after subsequent click on button the value remains at '1'. i.e. It increaments only once.
On debugging I found that when it reaches OnRequest() the value of count becomes '0'.
can you explain why & what need to be done to overcome this.
Thanks & regards
Ashutosh
Hi,
My first thought would be that you should set the cookie at the place (thus oninputprocessing) wher you increment the count variable. Can you show some more code in order to understand better the problem pls?
Eddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sure Eddy, here are they
OnRequest()->
DATA: page_data TYPE XSTRING.
DATA: name TYPE STRING.
* User Management can be using normal ABAP sy-name or other technique.
name = sy-uname.
* First get server side cookie
CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>GET_SERVER_COOKIE
EXPORTING
NAME = 'data1'
APPLICATION_NAME = runtime->application_name
APPLICATION_NAMESPACE = runtime->application_namespace
USERNAME = name
SESSION_ID = runtime->session_id
DATA_NAME = 'page_data'
CHANGING
DATA_VALUE = page_data.
* From server side cookie, restore all "persisted" page attributes
IF page_data IS NOT INITIAL.
IMPORT count = count
FROM DATA BUFFER page_data.
ENDIF.
OnManipulation()
DATA: page_data TYPE XSTRING.
DATA: name TYPE STRING.
* User Management can be using normal ABAP sy-name or other technique.
name = sy-uname.
EXPORT count FROM count
TO DATA BUFFER page_data.
* First get server side cookie
CALL METHOD CL_BSP_SERVER_SIDE_COOKIE=>SET_SERVER_COOKIE
EXPORTING
NAME = 'data1'
APPLICATION_NAME = runtime->application_name
APPLICATION_NAMESPACE = runtime->application_namespace
USERNAME = name
SESSION_ID = runtime->session_id
DATA_NAME = 'page_data'
DATA_VALUE = page_data .
[/code}
OnInputProcessing()->
[code]add 1 to count.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.