📄 libcgi_session.3
字号:
.TH "Session Handling" 3 "13 Mar 2003" "LibCGI" \" -*- nroff -*-.ad l.nh.SH NAMESession Handling \- .SH "Detailed Description".PP One of the most diferencials of LibCGI is its support to sessions, a mechanism that permits the application to keep variables trough the user's session, when he is visiting your website..SS "Functions".in +1c.ti -1c.RI "int \fBcgi_session_destroy\fP ()".br.RI "\fIDestroys the session.\fP".ti -1c.RI "char * \fBcgi_session_var\fP (const char *var_name)".br.RI "\fIGets session variable's value.\fP".ti -1c.RI "void \fBcgi_session_cookie_name\fP (const char *cookie_name)".br.RI "\fIDefines the name of the cookie that LibCGI will use to store session's ID.\fP".ti -1c.RI "void \fBcgi_session_save_path\fP (const char *path)".br.RI "\fIDefines where session control files will be saved.\fP".ti -1c.RI "int \fBcgi_session_register_var\fP (const char *name, const char *value)".br.RI "\fIRegister a variable in the current opened session.\fP".ti -1c.RI "int \fBcgi_session_alter_var\fP (const char *name, const char *new_value)".br.RI "\fIAlter session variable value.\fP".ti -1c.RI "int \fBcgi_session_var_exists\fP (const char *name)".br.RI "\fISearches for determined session variable.\fP".ti -1c.RI "int \fBcgi_session_unregister_var\fP (char *name)".br.RI "\fIUnregister some session variable.\fP".ti -1c.RI "int \fBcgi_session_start\fP ()".br.RI "\fIStarts a new session.\fP".in -1c.SH "Function Documentation".PP .SS "int cgi_session_alter_var (const char * name, const char * new_value)".PPAlter session variable value.Change session variable 'name' value to data pointer by 'new_value' .PP\fBParameters:\fP.RS 4\fIname\fP Session variable name to change .br\fInew_value\fP New session variable value .RE.PP\fBSee also:\fP.RS 4\fBcgi_session_register_var()\fP, \fBcgi_session_unregister_var()\fP .RE.PP.SS "void cgi_session_cookie_name (const char * cookie_name)".PPDefines the name of the cookie that LibCGI will use to store session's ID.This function works like \fBcgi_session_save_path()\fP. This functionality let you to use different names for each site, but remember, you cannot use multiple session for the same application yet..PP\fBParameters:\fP.RS 4\fIcookie_name\fP Name of the cookie to create .RE.PP\fBSee also:\fP.RS 4\fBcgi_session_save_path()\fP .RE.PP\fBNote:\fP.RS 4This function must be called before \fBcgi_session_start()\fP .RE.PP.SS "int cgi_session_destroy ()".PPDestroys the session.Destroys the current opened session, including all data. After session_destroy() was called, is not more possible to use session functions before an another call to session_start() .PP\fBReturns:\fP.RS 41 if no errors, 0 if. .RE.PP\fBSee also:\fP.RS 4\fBcgi_session_start\fP .PPcgi_session_error_message .RE.PP.SS "int cgi_session_register_var (const char * name, const char * value)".PPRegister a variable in the current opened session.Note that we are opening and closing the session file every time this function is called... ( I/O ^ 1000000 :-/ ) .PP\fBParameters:\fP.RS 4\fIname\fP Variable name .br\fIvalue\fP Variable value .RE.PP\fBSee also:\fP.RS 4\fBcgi_session_alter_var()\fP, \fBcgi_session_unregister_var()\fP .RE.PP.SS "void cgi_session_save_path (const char * path)".PPDefines where session control files will be saved.If in the your CGI you don't make a call to \fBcgi_session_save_path()\fP, LibCGI will use the default value, which is '/tmp/'. To see how to modify the value, see the following example. .brJust note you need to add '/' at the end of the directory name .PP.nf // your_cgi.c // Set 'session_files' directory under your CGI directory as the path // which LibCGI will use to store session files. cgi_session_save_path('session_files/'); .PP.PPNote that using this form, LibCGI will search for 'session_files' directory using relative path to your cgi application. For example, if your CGI script is located at /usr/local/httpd/web/your_name/cgi-bin/ directory, and you use the above declaration, the files for the session will be stored at /usr/local/httpd/web/your_name/cgi-bin/session_files directory. Resuming, the path is relative to where your application resides. .br.brAnd remember, LibCGI \fBdoes\fP \fBnot\fP create the directory for you..PP\fBParameters:\fP.RS 4\fIpath\fP Path, relative or absolute .RE.PP\fBSee also:\fP.RS 4\fBcgi_session_cookie_name\fP .RE.PP\fBNote:\fP.RS 4This function must be called before \fBcgi_session_start()\fP .RE.PP.SS "int cgi_session_start ()".PPStarts a new session.This function is responsible for starting and creating a new session. It must be called before any other session function, and every time before any HTML header has sent. .PP\fBSee also:\fP.RS 4session_destroy() .RE.PP.SS "int cgi_session_unregister_var (char * name)".PPUnregister some session variable.\fBParameters:\fP.RS 4\fIname\fP Session variable name to unregister .RE.PP\fBSee also:\fP.RS 4\fBcgi_session_var_exists()\fP, \fBcgi_session_register_var()\fP .RE.PP.SS "char* cgi_session_var (const char * var_name)".PPGets session variable's value.\fBParameters:\fP.RS 4\fIname\fP Session variable name to get the value .RE.PP\fBReturns:\fP.RS 4Variable contents if found, NULL if not. .RE.PP\fBSee also:\fP.RS 4\fBcgi_session_var_exists()\fP .RE.PP.SS "int cgi_session_var_exists (const char * name)".PPSearches for determined session variable.\fBParameters:\fP.RS 4\fIname\fP Session variable name to search .RE.PP\fBReturns:\fP.RS 41 if variable is registered, 0 if not .RE.PP\fBSee also:\fP.RS 4\fBcgi_session_var()\fP .RE.PP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -