Uses system. strutils, datasnap. dssession, sessionstoreobjectui;
Function tservermethods1.echostring (value: string): string; begin result: = value; end;
Function tservermethods1.reversestring (value: string): string; begin result: = system. strutils. reversestring (value); end;
// The client calls the HTTP storeobject method to store the session key
Function tservermethods1.storeobject (Key, A, B, C: string): string; var session: tdssession; inst: tmysessionclass; DEST: string; begin session: = tdssessionmanager. getthreadsession; if assigned (Session) then begin inst: = tmysessionclass. create; Inst. a: = A; Inst. b: = B; Inst. c: = C; Session. putobject (Key, insT );
// Return the URL wish session ID in it for // testing getting the session data back DEST: = 'HTTP: // localhost: 8080/datasnap/rest/tservermethods1/GetObject/'+ key + '? SID = '+ session. sessionname;
Form3.setthentext (DEST );
Exit (DEST); end;
Result: = 'failed' to add the object to the session'; end;
// The client calls HTTP GetObject to obtain the session content
Procedure tservermethods1.getobject (key: string; Out A, B, C: string); var session: tdssession; inst: tmysessionclass; begin session: = tdssessionmanager. getthreadsession; if assigned (Session) then begin inst: = tmysessionclass (Session. getObject (key); If assigned (insT) then begin A: = Inst. a; B: = Inst. b; C: = Inst. c; exit; end; A: = 'failed' to load data for key: '+ key; end;
HTTP-based datasnap session management