1Session Handling(3) Library Functions Manual Session Handling(3)
2
3
4
6 Session Handling -
7
9 One of the most diferencials of LibCGI is its support to sessions, a
10 mechanism that permits the application to keep variables trough the
11 user's session, when he is visiting your website.
12
13 Functions
14 int cgi_session_destroy ()
15 Destroys the session.
16 char * cgi_session_var (const char *var_name)
17 Gets session variable's value.
18 void cgi_session_cookie_name (const char *cookie_name)
19 Defines the name of the cookie that LibCGI will use to store
20 session's ID.
21 void cgi_session_save_path (const char *path)
22 Defines where session control files will be saved.
23 int cgi_session_register_var (const char *name, const char *value)
24 Register a variable in the current opened session.
25 int cgi_session_alter_var (const char *name, const char *new_value)
26 Alter session variable value.
27 int cgi_session_var_exists (const char *name)
28 Searches for determined session variable.
29 int cgi_session_unregister_var (char *name)
30 Unregister some session variable.
31 int cgi_session_start ()
32 Starts a new session.
33
35 int cgi_session_alter_var (const char * name, const char * new_value)
36 Alter session variable value.Change session variable 'name' value to
37 data pointer by 'new_value'
38
39 Parameters:
40 name Session variable name to change
41 new_value New session variable value
42
43 See also:
44 cgi_session_register_var(), cgi_session_unregister_var()
45
46 void cgi_session_cookie_name (const char * cookie_name)
47 Defines the name of the cookie that LibCGI will use to store session's
48 ID.This function works like cgi_session_save_path(). This functionality
49 let you to use different names for each site, but remember, you cannot
50 use multiple session for the same application yet.
51
52 Parameters:
53 cookie_name Name of the cookie to create
54
55 See also:
56 cgi_session_save_path()
57
58 Note:
59 This function must be called before cgi_session_start()
60
61 int cgi_session_destroy ()
62 Destroys the session.Destroys the current opened session, including all
63 data. After session_destroy() was called, is not more possible to use
64 session functions before an another call to session_start()
65
66 Returns:
67 1 if no errors, 0 if.
68
69 See also:
70 cgi_session_start
71
72 cgi_session_error_message
73
74 int cgi_session_register_var (const char * name, const char * value)
75 Register a variable in the current opened session.Note that we are
76 opening and closing the session file every time this function is
77 called... ( I/O ^ 1000000 :-/ )
78
79 Parameters:
80 name Variable name
81 value Variable value
82
83 See also:
84 cgi_session_alter_var(), cgi_session_unregister_var()
85
86 void cgi_session_save_path (const char * path)
87 Defines where session control files will be saved.If in the your CGI
88 you don't make a call to cgi_session_save_path(), LibCGI will use the
89 default value, which is '/tmp/'. To see how to modify the value, see
90 the following example.
91 Just note you need to add '/' at the end of the directory name
92
93 // your_cgi.c
94 // Set 'session_files' directory under your CGI directory as the path
95 // which LibCGI will use to store session files.
96
97 cgi_session_save_path('session_files/');
98
99
100
101 Note 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.
102
103 And remember, LibCGI does not create the directory for you.
104
105 Parameters:
106 path Path, relative or absolute
107
108 See also:
109 cgi_session_cookie_name
110
111 Note:
112 This function must be called before cgi_session_start()
113
114 int cgi_session_start ()
115 Starts a new session.This function is responsible for starting and
116 creating a new session. It must be called before any other session
117 function, and every time before any HTML header has sent.
118
119 See also:
120 session_destroy()
121
122 int cgi_session_unregister_var (char * name)
123 Unregister some session variable.Parameters:
124 name Session variable name to unregister
125
126 See also:
127 cgi_session_var_exists(), cgi_session_register_var()
128
129 char* cgi_session_var (const char * var_name)
130 Gets session variable's value.Parameters:
131 name Session variable name to get the value
132
133 Returns:
134 Variable contents if found, NULL if not.
135
136 See also:
137 cgi_session_var_exists()
138
139 int cgi_session_var_exists (const char * name)
140 Searches for determined session variable.Parameters:
141 name Session variable name to search
142
143 Returns:
144 1 if variable is registered, 0 if not
145
146 See also:
147 cgi_session_var()
148
149LibCGI 13 Mar 2003 Session Handling(3)