LIBCGI_SESSION(3)
β¨ Session Handling β¨
okay bestie, this one's from the Library Functions Manual, section 3 β it's giving libcgi session energy and honestly? obsessed. π
πΈ NAME πΈ
Session Handling β the whole session situation. π
π¦ Detailed Description π¦
ok so here's the tea, and it's a big one: one of the most diferencials (their spelling, not mine, we're keeping it π) of LibCGI is that it supports sessions β a mechanism that lets your app keep variables trough the user's session, when he is visiting your website. π
literally the whole vibe: variables that remember you while you're wandering around the site. main character behavior fr fr. π
π§ Functions π§
int cgi_session_destroy()β Destroys the session. πchar * cgi_session_var(const char *var_name)β Gets session variable's value.void cgi_session_cookie_name(const char *cookie_name)β Defines the name of the cookie that LibCGI will use to store session's ID. πvoid cgi_session_save_path(const char *path)β Defines where session control files will be saved.int cgi_session_register_var(const char *name, const char *value)β Register a variable in the current opened session.int cgi_session_alter_var(const char *name, const char *new_value)β Alter session variable value.int cgi_session_var_exists(const char *name)β Searches for determined session variable.int cgi_session_unregister_var(char *name)β Unregister some session variable.int cgi_session_start()β Starts a new session. β¨
π Function Documentation π
π int cgi_session_alter_var(const char * name, const char * new_value)
Alter session variable value. Change session variable name value to data pointer by new_value. it's giving glow-up but for a variable π
Parameters:
nameβ Session variable name to changenew_valueβ New session variable value
See also:
cgi_session_register_var(), cgi_session_unregister_var()
π void cgi_session_cookie_name(const char * cookie_name)
Defines the name of the cookie that LibCGI will use to store session's ID. This function works like cgi_session_save_path(). This functionality let you to use different names for each site, but remember β you cannot use multiple session for the same application yet. π
Parameters:
cookie_nameβ Name of the cookie to create
See also:
cgi_session_save_path()
Note: This function must be called before cgi_session_start() β οΈ
π int cgi_session_destroy()
Destroys 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(). it's giving ghosted, no cap. π«Ά
Returns:
1 if no errors, 0 if.
See also:
cgi_session_start
cgi_session_error_message
π int cgi_session_register_var(const char * name, const char * value)
Register 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 :-/ ) β yeah bestie, the I/O is I/O-ing. π
Parameters:
nameβ Variable namevalueβ Variable value
See also:
cgi_session_alter_var(), cgi_session_unregister_var()
π¦ void cgi_session_save_path(const char * path)
Defines where session control files will be saved. If in the your CGI you don't make a call to cgi_session_save_path(), LibCGI will use the default value, which is '/tmp/'. To see how to modify the value, see the following example.
Just note you need to add '/' at the end of the directory name π
// 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/');
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.
And remember, LibCGI does not create the directory for you. π¨
Parameters:
pathβ Path, relative or absolute
See also:
cgi_session_cookie_name
Note: This function must be called before cgi_session_start() β οΈ
β¨ int cgi_session_start()
Starts 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. π
See also:
session_destroy()
π§ int cgi_session_unregister_var(char * name)
Unregister some session variable.
Parameters:
nameβ Session variable name to unregister
See also:
cgi_session_var_exists(), cgi_session_register_var()
π char* cgi_session_var(const char * var_name)
Gets session variable's value.
Parameters:
nameβ Session variable name to get the value
Returns:
Variable contents if found, NULL if not.
See also:
cgi_session_var_exists()
πΈ int cgi_session_var_exists(const char * name)
Searches for determined session variable.
Parameters:
nameβ Session variable name to search
Returns:
1 if variable is registered, 0 if not
See also:
cgi_session_var()
LibCGI Β· 13 Mar 2003 Β· Session Handling(3)
and that's the whole page bestie, mwah π this lil session manual is by LibCGI and it's dated 13 Mar 2003, slay, go register some variables πβ¨
π¦ where this page comes from
- fedora 43: libcgi-devel 1.0-43.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: libcgi-devel 1.0-43.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: libcgi-devel 1.0-44.fc44 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: libcgi-devel 1.0-44.fc44 Β· LicenseRef-Callaway-LGPLv2+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms