SESSION API
1. wbGetSession
wbGetSession returns the current session to the requesting user.
If there is no session, it creates a new session and returns it. To ensure that the session is managed correctly, it must be called at least once before any result is sent to the response.
- 
Prototype #include <wbapi.h> SESSION* wbGetSession(WBSVCINFO *rqst) 
- 
Return value If the wbGetSession() call is successful, a valid session is returned. 
- 
Example <getsession.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR = "/user2/haninho/webtob/ap", PORT = "7654" *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SvrType = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc = 2 getsession SVGNAME = webapg, MinProc = 1, MaxProc = 2 *SERVICE test SVrname= getsession *URI uri1 uri = "/svct/", SvrType = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i getsession.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes requests, and the file name is getsession.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { char *id; SESSION *session; session = wbGetSession(rqst); id = wbSessionGetId(session); wbPrint(rqst,”session id= %s”, id); wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c getsession 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbGetRequestedSessionId(), wbGetSessionId(), wbSessionGetValue(),wbSessionGetLastAccessedTime(), wbSessionGetMaxInactiveInterval(), wbSessionGetCreationTime(), wbSessionGetValueNames() 
2. wbSessionGetCreationTime
wbSessionGetCreationTime returns the time the current session was created.
Returns the time the session was created as a long type representing the time in milliseconds since midnight, January 1, 1970 GMT.
- 
Prototype #include <wbapi.h> long wbSessionGetCreationTime(SESSION *session) 
- 
Return value If the wbSessionGetCreationTime() call is successful, it returns the time the session was created. 
- 
Example <createtime.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR = "/user2/haninho/webtob/ap", PORT = "7654" *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SvrType = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc = 2 createtime SVGNAME = webapg, MinProc = 1, MaxProc = 2 *SERVICE test SVrname= createtime *URI uri1 uri = "/svct/", SvrType = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i createtime.m 
- 
Create a service table. $wsgst 
- 
Create a source file. The following is an example WBAPI program that processes a request, named createtime.c. #include <stdio.h> #include <string.h> #include "../usrinc/atmi.h" #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { long time; SESSION *session; session = wbGetSession(rqst); time = wbSessionGetCreationTime(session); wbPrint(rqst, "create time = %ld<br>", time); wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c createtime 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbGetRequestedSessionId(), wbGetSession(), wbGetSessionId(), wbSessionGetLastAccessedTime(), wbSessionGetMaxInactiveInterval(), wbSessionGetValue(), wbSessionGetValueNames() 
3. wbSessionGetId
wbSessionGetId returns the string identifier (ID) assigned to the current session.
- 
Prototype #include <wbapi.h> char* wbSessionGetId(SESSION *session) 
- 
Return value If the wbSessionGetId() call is successful, it returns the string assigned to the session. 
- 
Example <getid.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR = "/user2/haninho/webtob/ap", PORT = "7654" *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SvrType = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc = 2 getid SVGNAME = webapg, MinProc = 1, MaxProc = 2 *SERVICE test SVrname= getid *URI uri1 uri = "/svct/", SvrType = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i getid.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes a request, and the file name is getid.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { int ex; char *id; SESSION *session; session = wbGetSession(rqst); ex = wbSessionIsNew(session); id = wbSessionGetId(session); wbPrint(rqst, "session id = %s<br>", id); wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c getid 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbGetRequestedSessionId(), wbSessionGetCreationTime(), wbGetSession(), wbSessionGetLastAccessedTime(), wbSessionGetMaxInactiveInterval(), wbSessionGetValue(), wbSessionGetValueNames() 
4. wbSessionGetLastAccessedTime
wbSessionGetLastAccessedTime returns the time when the client last sent a request.
Returns the time of the last request sent by the client during this session, represented as a long-type data value indicating the time in milliseconds since midnight, January 1, 1970, GMT.
- 
Prototype #include <wbapi.h> long wbSessionGetLastAccessedTime(SESSION *session) 
- 
Return value If the wbSessionGetlastAccessedTime() call is successful, it returns the time the client last sent a request. 
- 
Example <lasttime.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR = "/user2/haninho/webtob/ap", PORT = "7654" *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SvrType = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc = 2 lasttime SVGNAME = webapg, MinProc = 1, MaxProc = 2 *SERVICE test SVrname= lasttime *URI uri1 uri = "/svct/", SvrType = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i lasttime.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes a request, named lasttime.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { long last; SESSION *session; session = wbGetSession(rqst); last = wbSessionGetLastAccessedTime(session); wbPrint(rqst, "session last access time = %ld<br>", last); wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c lasttime 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbGetRequestedSessionId(), wbSessionGetCreationTime(), wbGetSessionId(), wbGetSession(), wbSessionGetMaxInactiveInterval(), wbSessionGetValue(), wbSessionGetValueNames() 
5. wbSessionGetValue
wbSessionGetValue finds and returns the value with the specified name in the session.
- 
Prototype #include <wbapi.h> int wbSessionGetValue(SESSION *session, char *name, int *len) 
- 
Return value Finds and returns the value of the specified name in the session. If the specified name does not exist, NULL is returned. 
- 
Example <getvalue.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR = "/user2/haninho/webtob/ap", PORT = "7654" *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SvrType = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc = 2 getvalue SVGNAME = webapg, MinProc = 1, MaxProc = 2 *SERVICE test SVrname= getvalue *URI uri1 uri = "/svct/", SvrType = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i getvalue.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes a request, and the file name is getvalue.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst){ int len; char *value, *value2; SESSION *session; SESSION *session1; SESSION *session2; session= wbGetSession(rqst); session1 = wbSessionSetValue(session, "name", "webtob",6); session2 = wbSessionSetValue(session1, "tel", "123-1234",8); value = wbSessionGetValue(session2 , "name",&len); value2 = wbSessionGetValue(session2 , "tel",&len); wbPrint(rqst, "session value = %s<br>", value); wbPrint(rqst, "session value = %s", value2); wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c getvalue 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbGetRequestedSessionId(), wbSessionGetCreationTime(), wbGetSessionId(), wbSessionGetLastAccessedTime(), wbSessionGetMaxInactiveInterval(), wbGetSession(), wbSessionGetValueNames() 
6. wbSessionGetValueNames
wbSessionGetValueNames returns an array containing the names of all values stored in the current session.
- 
Prototype #include <wbapi.h> char** wbSessionGetValueNames(SESSION *session, int *len) 
- 
Return value Finds and returns the names of all values in the session. If no values are found, NULL is returned. 
- 
Example <valuename.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR = "/user2/haninho/webtob/ap", PORT = "7654" *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SvrType = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc = 2 valuename SVGNAME = webapg, MinProc = 1, MaxProc = 2 *SERVICE test SVrname= valuename *URI uri1 uri = "/svct/", SvrType = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i valuename.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes a request, named valuename.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { char **na; int len; SESSION *session; SESSION *session1; SESSION *session2; session= wbGetSession(rqst); session1 = wbSessionSetValue(session, "name", "webtob",6); session2 = wbSessionSetValue(session1, "tel", "123-1234",8); na = wbSessionGetValueNames(session2,&len); wbPrint(rqst,"name1 = %s\n<br>",*na); wbPrint(rqst,"name2 = %s\n",*(na+1)); wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c valuename 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbGetRequestedSessionId(), wbSessionGetCreationTime(), wbGetSessionId(), wbSessionGetLastAccessedTime(), wbSessionGetMaxInactiveInterval(), wbSessionGetValue(), wbGetSession() 
7. wbSessionGetMaxInactiveInterval
wbSessionGetMaxInactiveInterval gets the maximum inactive interval time in seconds for a session. The default is 1800 seconds, or 30 minutes.
- 
Prototype #include <wbapi.h> int wbSessionGetMaxInactiveInterval(SESSION *session) 
- 
Return value If the wbSessionGetMaxInactiveInterval() call is successful, it returns the inactive interval time in seconds specified for the session. 
- 
Example <getinterval.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR = "/user2/haninho/webtob/ap", PORT = "7654" *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SvrType = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc = 2 getinterval SVGNAME = webapg, MinProc = 1, MaxProc = 2 *SERVICE test SVrname= getinterval *URI uri1 uri = "/svct/", SvrType = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i getinterval.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes requests, and the file name is getinterval.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { int ex=0, interval, check; SESSION *session; session = wbGetSession(rqst); ex = wbSessionIsNew(session); interval = wbSessionGetMaxInactiveInterval(session); if(ex == 1) { wbPrint(rqst, "session inactive Interval = %d<br>", interval); } else { wbPrint(rqst," fail create session"); } check = wbSessionSetMaxInactiveInterval(session, 3000); interval = wbSessionGetMaxInactiveInterval(session); wbPrint(rqst, "session new inactive Interval = %d<br>", interval); wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c getinterval 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbGetRequestedSessionId(), wbSessionGetCreationTime(), wbGetSessionId(), wbSessionGetLastAccessedTime(), wbGetSession (), wbSessionGetValue(), wbSessionGetValueNames() 
8. wbSessionSetMaxInactiveInterval
wbSessionSetMaxInactiveInterval resets the maximum inactive interval time for a session in seconds. The default value is 1800 seconds, or 30 minutes.
- 
Prototype #include <wbapi.h> int wbSessionSetMaxInactiveInterval(SESSION *session, int interval) 
- 
Return value If the wbSessionSetMaxInactiveInterval() call succeeds, it returns 1, otherwise it returns 0. 
- 
Example <setinterval.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR = "/user2/haninho/webtob/ap", PORT = "7654" *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SvrType = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc = 2 setinterval SVGNAME = webapg, MinProc = 1, MaxProc = 2 *SERVICE test SVrname= setinterval *URI uri1 uri = "/svct/", SvrType = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i setinterval.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes requests, and the file name is setinterval.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { int ex=0, interval, check; SESSION *session; session = wbGetSession(rqst); ex = wbSessionIsNew(session); interval = wbSessionGetMaxInactiveInterval(session); if(ex == 1) { wbPrint(rqst, "session inactive Interval = %d<br>", interval); } else { wbPrint(rqst," fail create session"); } check = wbSessionSetMaxInactiveInterval(session, 3000); interval = wbSessionGetMaxInactiveInterval(session); wbPrint(rqst, "session new inactive Interval = %d<br>", interval); wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c setinterval 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbSessionSetValue() 
9. wbSessionSetValue
wbSessionSetValue stores a value for a specified name in the session. If a value with the specified name already exists, it is replaced.
- 
Prototype #include <wbapi.h> SESSION* wbSessionSetValue(SESSION *session, char *name, int len) 
- 
Return value The session containing the specified name value is returned. 
- 
Example <setvalue.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR = "/user2/haninho/webtob/ap", PORT = "7654" *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SvrType = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc = 2 setvalue SVGNAME = webapg, MinProc = 1, MaxProc = 2 *SERVICE test SVrname= setvalue *URI uri1 uri = "/svct/", SvrType = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i setvalue.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes a request, and the file name is setvalue.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { int len; char *value, *value2; SESSION *session; SESSION *session1; SESSION *session2; session= wbGetSession(rqst); session1 = wbSessionSetValue(session, "name", "webtob",6); session2 = wbSessionSetValue(session1, "tel", "123-1234",8); value = wbSessionGetValue(session2 , "name",&len); value2 = wbSessionGetValue(session2 , "tel",&len); wbPrint(rqst, "session value = %s<br>", value); wbPrint(rqst, "session value = %s", value2); wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c setvalue 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbSessionSetMaxInactiveInterval() 
10. wbSessionRemoveValue
wbSessionRemoveValue removes a value stored in the session. If there is no value stored with the argument name, it does nothing.
- 
Prototype #include <wbapi.h> int wbSessionRemoveValue(SESSION *session, char *name) 
- 
Return value If the wbSessionRemoveValue() call is successful, it returns 1; if it fails, it returns 0. 
- 
Example <remove.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR="/user2/haninho/webtob/ap", PORT = “7654” *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SVRTYPE = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc =2 remove SVGNAME = webapg, MinProc = 1, MaxProc = 2, *SERVICE test SVRNAME = remove *URI wbapi Uri = "/svct/", Svrtype = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i remove.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes the request, named remove.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { int ex, len; char *value, *value2; SESSION *session; SESSION *newsession; session = wbGetSession(rqst); newsession = wbSessionSetValue(session, "name", "webtob",7); value = wbSessionGetValue(newsession , "name",&len); wbPrint(rqst, "session value = %s<br>", value); ex = wbSessionRemoveValue(newsession, "name"); if(ex ==1) { wbPrint(rqst, "delete value<br>"); } value2 = wbSessionGetValue(newsession , "name", &len); if(value2 !=NULL) { wbPrint(rqst, "session value = %s<br>", value2); } else { wbPrint(rqst, "session value is null<br>"); } wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c remove 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbSessionGetValue(), wbSessionSetValue() 
11. wbSessionIsNew
wbSessionIsNew returns a value indicating whether the session is new or not. A session is new if the server created the session but the client did not approve the session to be merged.
- 
Prototype #include <wbapi.h> int wbSessionIsNew(SESSION *session) 
- 
Return value After calling wbSessionIsNew(), it returns 1 if the session is new, 0 if the client has already accepted the session. 
- 
Example <isnew.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR="/user2/haninho/webtob/ap", PORT = “7654” *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SVRTYPE = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc =2 isnew SVGNAME = webapg, MinProc = 1, MaxProc = 2, *SERVICE test SVRNAME = isnew *URI wbapi Uri = "/svct/", Svrtype = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i isnew.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes a request, and the file name is isnew.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { int ex=0; SESSION *session; session = wbGetSession(rqst); ex = wbSessionIsNew(session); if(ex == 1) { wbPrint(rqst, "new session"); } else { wbPrint(rqst," old session"); } wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c isnew 
- 
The following is the screen where the results are printed. When you request a WBAPI service with a browser, you get the following result:  
 
- 
- 
Related functions wbGetRequestedSessionId(), wbIsRequestedSessionIdValid(), wbSessionInvalidate() 
12. wbSessionInvalidate
wbSessionInvalidate invalidates the session.
- 
Prototype #include <wbapi.h> int wbSessionInvalidate(SESSION *session) 
- 
Return value If the wbSessionInvalidate() call succeeds, it returns 1; if it fails, it returns 0. 
- 
Example <invalidate.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR="/user2/haninho/webtob/ap", PORT = “7654” *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SVRTYPE = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc =2 invalidate SVGNAME = webapg, MinProc = 1, MaxProc = 2, *SERVICE test SVRNAME = invalidate test2 SVRNAME = invalidate *URI wbapi Uri = "/svct/", Svrtype = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i invalidate.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes a request, named invalidate.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { char *id; SESSION *session; session = wbGetSession(rqst); id = wbSessionGetId(session); wbPrint(rqst, "<html><body>"); wbPrint(rqst, "<h1>session id is %s </h1><br>",id); wbPrint(rqst, "<form method=get action=/svct/test2>"); wbPrint(rqst, "<td><input type=submit value=suit></td>"); wbPrint(rqst, "</form>"); wbPrint(rqst, "</body></html>"); wbReturn(rqst, WBSUCCESS); } test2(WBSVCINFO *rqst) { int date; char *id; SESSION *session; session= wbGetSession(rqst); date = wbSessionInvalidate(session); id = wbSessionGetId(session); if(id !=NULL) { wbPrint(rqst, "<h1>session id is %s </h1><br>",id); } else { wbPrint(rqst, "<hi>Session id is Null</h1>"); } if(date == 1) { wbPrint(rqst, "session is invalidate=%d<br>",date); } else { wbPrint(rqst, "session is validate=%d<br>",date); } wbPrint(rqst, "<html><body>"); wbPrint(rqst, "<form method=get action=/svct/test2>"); wbPrint(rqst, "<td><input type=submit value=suit></td>"); wbPrint(rqst, "</form>"); wbPrint(rqst, "</body></html>"); wbReturn(rqst, WBSUCCESS);}
- 
Compile the C file created with WBAPI using the Makefile file. $compile c invalidate 
- 
The following is the screen where the results are printed. Click the [suit] button.  Click the [suit] button again.  
 
- 
- 
Related functions wbGetRequestedSessionId(), wbIsRequestedSessionIdValid(), wbSessionIsNew() 
13. wbGetRequestedSessionId
wbGetRequestedSessionId returns the session ID specified by the user.
However, this may not correspond to an actual session ID. For example, if the session has ended before the request was made, the server will create a new session ID and use that instead.
- 
Prototype #include <wbapi.h> char* wbGetRequestedSessionId(WBSVCINFO *rqst) 
- 
Return value If the wbGetRequestedSessionId() call is successful, it returns the session ID. 
- 
Example <sessionid.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR="/user2/haninho/webtob/ap", PORT = “7654” *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SVRTYPE = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc =2 sessionid SVGNAME = webapg, MinProc = 1, MaxProc = 2, *SERVICE test SVRNAME = sessionid test2 SVRNAME = sessionid *URI wbapi Uri = "/svct/", Svrtype = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i sessionid.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes requests, and the file name is sessionid.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { char *id; SESSION *session; session = wbGetSession(rqst); id = wbSessionGetId(session); wbPrint(rqst, "<html><body>"); wbPrint(rqst, "<h1>session id is %s </h1><br>",id); wbPrint(rqst, "<html><body>"); wbPrint(rqst, "<form method=get action=/svct/test2>"); wbPrint(rqst, "<td><input type=submit value=suit></td>"); wbPrint(rqst, "</form>"); wbPrint(rqst, "</body></html>"); wbReturn(rqst, WBSUCCESS); } test2(WBSVCINFO *rqst) { char *sessionid; sessionid = wbGetRequestedSessionId(rqst); if(sessionid != NULL) { wbPrint(rqst, "sessionId is = %s<br>",sessionid); } else { wbPrint(rqst, "sessionId is NULL<br>"); } wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c sessionid 
- 
The following is the screen where the results are printed. Click the [suit] button.  Click the [suit] button again.  
 
- 
- 
Related functions wbSessionIsNew(), wbIsRequestedSessionIdValid(), wbSessionInvalidate() 
14. wbIsRequestedSessionIdValid
wbIsRequestedSessionIdValid verifies whether the session requested by the client is a valid session.
If the session requested by the client is valid and currently in use, it returns 1. For newly created sessions or expired sessions, it returns 0.
- 
Prototype #include <wbapi.h> int wbIsRequestedSessionIdValid(WBSVCINFO *rqst) 
- 
Return value Calling wbIsRequestedSessionIdVaild() returns 1 if the session is in use, and 0 if it is no longer in use. 
- 
Example <idvalid.m> *DOMAIN webtob1 *NODE tmaxh1 WEBTOBDIR="/user2/haninho/webtob", SHMKEY = 54777, DOCROOT="/user2/haninho/webtob/docs", APPDIR="/user2/haninho/webtob/ap", PORT = “7654” *SVRGROUP htmlg NODENAME = "tmaxh1", SvrType = HTML webapg NODENAME = "tmaxh1", SVRTYPE = WEBSTD *SERVER html SVGNAME = htmlg, MinProc = 1, MaxProc =2 idvalid SVGNAME = webapg, MinProc = 1, MaxProc = 2, *SERVICE test SVRNAME = idvalid test2 SVRNAME = idvalid *URI wbapi Uri = "/svct/", Svrtype = WEBSTD *EXT htm MimeType = "text/html", SvrType = HTML- 
Compile the configuration file (Config-file). $wscfl –i idvalid.m 
- 
Create a service table. $wsgst 
- 
Generate a source file. The following is an example WBAPI program that processes requests, and the file name is sessionid.c. #include <stdio.h> #include <string.h> #include "../usrinc/wbapi.h" test(WBSVCINFO *rqst) { char *id; SESSION *session; session = wbGetSession(rqst); id = wbSessionGetId(session); wbPrint(rqst, "<html><body>"); wbPrint(rqst, "<h1>session id is %s </h1><br>",id); wbPrint(rqst, "<html><body>"); wbPrint(rqst, "<form method=get action=/svct/test2>"); wbPrint(rqst, "<td><input type=submit value=suit></td>"); wbPrint(rqst, "</form>"); wbPrint(rqst, "</body></html>"); wbReturn(rqst, WBSUCCESS); } test2(WBSVCINFO *rqst) { int date; date = wbIsRequestedSessionIdValid(rqst); if(date == 1) { wbPrint(rqst, "session is used=%d<br>",date); } else { wbPrint(rqst, "session is not used=%d<br>",date); } wbPrint(rqst, "<html><body>"); wbPrint(rqst, "<form method=get action=/svct/test2>"); wbPrint(rqst, "<td><input type=submit value=suit></td>"); wbPrint(rqst, "</form>"); wbPrint(rqst, "</body></html>"); wbReturn(rqst, WBSUCCESS); }
- 
Compile the C file created with WBAPI using the Makefile file. $compile c sessionid 
- 
The following is the screen where the results are printed. [suit] Click the button.  Click the [suit] button again.  
 
- 
- 
Related functions wbGetRequestedSessionId(), wbSessionIsNew(), wbSessionInvalidate()