session_name
Description
The session_name of Session for PHP gets and/or sets the current session name.
Syntax
session_name( ?string $name = null ): string|false
Parameters
name
The session name references the name of the session, which is used in cookies and URLs (e.g. PHPSESSID). It should contain only alphanumeric characters; it should be short and descriptive (i.e. for users with enabled cookie warnings). If name is specified and not null, the name of the current session is changed to its value.
WARNING: The session name can't consist of digits only, at least one letter must be present. Otherwise a new session id is generated every time.
Return
Returns the name of the current session. If name is given and function updates the session name, name of the old session is returned, or false on failure.
Examples
1 · void
<? $return = session_name(); echo $return;
PHPSESSID
2 · name · previous
<? $name = "myname"; $return = session_name($name); echo $return;
PHPSESSID
3 · name · current
<? $name = "myname"; session_name($name); $return = session_name(); echo $return;
myname
Links
Related
Session
- session_abort
- session_cache_expire
- session_cache_limiter
- session_commit
- session_create_id
- session_decode
- session_destroy
- session_encode
- session_gc
- session_get_cookie_params
- session_id
- session_module_name
- session_regenerate_id
- session_register_shutdown
- session_reset
- session_save_path
- session_set_cookie_params
- session_set_save_handler
- session_start
- session_status
- session_unset
- session_write_close