module Eliom_sessions:This module contains the functions you need to get (or set) information about the request or the session.sig..end
Be very carefull if you use several sessions concurrently, as they may have different duration (one may be closed while the other are not). Duration of service sessions is sometimes shorter than volatile data sessions, which is usually shorter than persistent sessions.
If you want several sessions of the same type for one site,
you can choose a personalized session name by giving the optional
parameter ?session_name.
It is highly recommended to put all the sessions for one user in one session group. Thus, it will be possible to implement features like "close all opened sessions" for one user, or limitation of the number of sessions one user can open concurrently, or setting data for one group of sessions.
The default duration of session may be set in Ocsigen's configuration file, as options for the Eliom module. Each Eliom site can override these options using functions of this module.
Setting sessions timeout in the configuration file. Example:
<extension findlib-package="ocsigen.ext.eliom">
<datatimeout value="3600"> (* in memory data sessions *)
<persistenttimeout value="infinity"> (* persistent session data *)
<servicetimeout value="3600"> (* session services *)
<volatiletimeout value="3600"> (* both session services and
in memory data sessions *)
</extension>
Getting information about the request
type server_params
val get_user_agent : sp:server_params -> stringval get_full_url : sp:server_params -> stringval get_remote_ip : sp:server_params -> stringval get_remote_inet_addr : sp:server_params -> Unix.inet_addrUnix.inet_addr (defined in OCaml's standard library).val get_current_full_path_string : sp:server_params -> stringval get_current_full_path : sp:server_params -> Ocsigen_lib.url_pathOcsigen_lib.url_pathval get_original_full_path_string : sp:server_params -> stringval get_original_full_path : sp:server_params -> Ocsigen_lib.url_pathval get_current_sub_path_string : sp:server_params -> stringval get_current_sub_path : sp:server_params -> Ocsigen_lib.url_pathOcsigen_lib.url_path.
The sub-path is the full path without the path of the site (set in the
configuration file).val get_header_hostname : sp:server_params -> string optionval get_default_hostname : sp:server_params -> string<host defaulthostname="...">).val get_hostname : sp:server_params -> stringHost header sent by the browser or the default hostname
set in the configuration file, depending on server configuration
(<usedefaulthostname/> option).val get_default_port : sp:server_params -> int<host defaulthttpport="...">).val get_default_sslport : sp:server_params -> int<host defaulthttpsport="...">).val get_server_port : sp:server_params -> intval get_ssl : sp:server_params -> boolval get_suffix : sp:server_params -> Ocsigen_lib.url_path option : sp:server_params -> string Ocsigen_lib.String_Table.tNone means no
timeout.
The optional parameter ?recompute_expdates is false by
default. If you set it to true, the expiration dates for all
sessions in the table will be recomputed with the new timeout.
That is, the difference between the new timeout and the old one
will be added to their expiration dates (by another Lwt thread).
Sessions whose timeout has been set individually with
Eliom_sessions.set_volatile_session_timeout won't be affected.
If ~session_name is not present, it is the default for all session names,
and in that case recompute_expdates is ignored. ~session_name:None
means the default session name.
If ~override_configfile is true (default (false),
then the function will set the timeout even if it has been
modified in the configuration file.
It means that by default, these functions have no effect
if there is a value in the configuration file.
This gives the ability to override the values choosen by the module
in the configuration file.
Use ~override_configfile:true for example if your
Eliom module wants to change the values afterwards
(for example in the site configuration Web interface).
Warning: If you use one of these functions after the
initialisation phase, you must give the ~sp parameter, otherwise
it will raise the exception
Eliom_common.Eliom_function_forbidden_outside_site_loading. This
remark also applies to get_* functions.
val set_global_volatile_session_timeout : ?session_name:string option ->
?sp:server_params ->
?recompute_expdates:bool -> ?override_configfile:bool -> float option -> unitval set_global_service_session_timeout : ?session_name:string option ->
?sp:server_params ->
?recompute_expdates:bool -> ?override_configfile:bool -> float option -> unitval set_global_volatile_data_session_timeout : ?session_name:string option ->
?sp:server_params ->
?recompute_expdates:bool -> ?override_configfile:bool -> float option -> unitval set_global_persistent_data_session_timeout : ?session_name:string option ->
?sp:server_params ->
?recompute_expdates:bool -> ?override_configfile:bool -> float option -> unitval get_global_service_session_timeout : ?session_name:string ->
?sp:server_params -> unit -> float optionval get_global_volatile_data_session_timeout : ?session_name:string ->
?sp:server_params -> unit -> float optionval get_global_persistent_data_session_timeout : ?session_name:string ->
?sp:server_params -> unit -> float optionval set_service_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> float option -> unitNone = no timeoutval unset_service_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unitval get_service_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> unit -> float optionNone = no timeoutval set_volatile_data_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> float option -> unitNone = no timeoutval unset_volatile_data_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unitval get_volatile_data_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> unit -> float optionNone = no timeoutval set_volatile_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> float option -> unitNone = no timeoutval unset_volatile_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unitval set_persistent_data_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> float option -> unit Lwt.tNone = no timeoutval unset_persistent_data_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unit Lwt.tval get_persistent_data_session_timeout : ?session_name:string ->
?secure:bool -> sp:server_params -> unit -> float option Lwt.tNone = no timeouttype 'a session_data =
| |
No_data |
| |
Data_session_expired |
| |
Data of |
val set_service_session_group : ?set_max:int ->
?session_name:string ->
?secure:bool -> sp:server_params -> string -> unit?set_max parameter is present, also sets the maximum
number of sessions in the group. None means "no limitation".
If ~secure is false when the protocol is https, it will affect
the unsecure session, otherwise, il will affect the secure session in
https, the unsecure one in http.val unset_service_session_group : ?set_max:int ->
?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unitval get_service_session_group : ?session_name:string ->
?secure:bool ->
sp:server_params -> unit -> string session_dataNone.val set_volatile_data_session_group : ?set_max:int ->
?session_name:string ->
?secure:bool -> sp:server_params -> string -> unit?set_max parameter is present, also sets the maximum
number of sessions in the group. None means "no limitation".val unset_volatile_data_session_group : ?set_max:int ->
?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unitval get_volatile_data_session_group : ?session_name:string ->
?secure:bool ->
sp:server_params -> unit -> string session_dataNone.val set_persistent_data_session_group : ?set_max:int option ->
?session_name:string ->
?secure:bool -> sp:server_params -> string -> unit Lwt.t?set_max parameter is present, also sets the maximum
number of sessions in the group. None means "no limitation".val unset_persistent_data_session_group : ?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unit Lwt.tval get_persistent_data_session_group : ?session_name:string ->
?secure:bool ->
sp:server_params ->
unit -> string session_data Lwt.tNone.None means "no limit". This won't modify existing groups. That
value will be used only as default value if you do not specify the
optional parameter ?set_max of function
Eliom_sessions.set_volatile_data_session_group.
If there is no group, the number of sessions is limitated by sub network
(which can be a problem for example if the server is behind a
reverse proxy).
It is highly recommended to use session groups!
val set_default_max_service_sessions_per_group : ?sp:server_params -> ?override_configfile:bool -> int -> unitval set_default_max_volatile_data_sessions_per_group : ?sp:server_params -> ?override_configfile:bool -> int -> unitval set_default_max_persistent_data_sessions_per_group : ?sp:server_params ->
?override_configfile:bool -> int option -> unitval set_default_max_service_sessions_per_subnet : ?sp:server_params -> ?override_configfile:bool -> int -> unitval set_default_max_volatile_data_sessions_per_subnet : ?sp:server_params -> ?override_configfile:bool -> int -> unitval set_default_max_volatile_sessions_per_group : ?sp:server_params -> ?override_configfile:bool -> int -> unitval set_default_max_volatile_sessions_per_subnet : ?sp:server_params -> ?override_configfile:bool -> int -> unitval set_ipv4_subnet_mask : ?sp:server_params ->
?override_configfile:bool -> int32 -> unitval set_ipv6_subnet_mask : ?sp:server_params ->
?override_configfile:bool -> int64 * int64 -> unitval set_max_service_sessions_for_group_or_subnet : ?session_name:string ->
?secure:bool -> sp:server_params -> int -> unitval set_max_volatile_data_sessions_for_group_or_subnet : ?session_name:string ->
?secure:bool -> sp:server_params -> int -> unitNone means the cookie will expire
when the browser is closed. Note: there is no way to set cookies
for an infinite time on browsers. : ?session_name:string ->
?secure:bool -> sp:server_params -> float option -> unit : ?session_name:string ->
?secure:bool -> sp:server_params -> float option -> unit : ?session_name:string ->
?secure:bool -> sp:server_params -> float option -> unit : ?session_name:string ->
?secure:bool -> sp:server_params -> float option -> unit Lwt.tval get_request_cache : sp:server_params -> Polytables.tval clean_request_cache : sp:server_params -> unitval get_link_too_old : sp:server_params -> booltrue if the coservice called has not been found.
In that case, the current service is the fallback.val get_expired_service_sessions : sp:server_params -> string listval get_previous_extension_error_code : sp:server_params -> intval get_tmp_filename : Ocsigen_lib.file_info -> stringval get_filesize : Ocsigen_lib.file_info -> int64val get_original_filename : Ocsigen_lib.file_info -> stringval get_config : unit -> Simplexmlparser.xml list<site> and </site>).
Warning: You must call that function during the initialisation of
your module (not during a Lwt thread or a service)
otherwise it will raise the exception
Eliom_common.Eliom_function_forbidden_outside_site_loading.
If you want to build a statically linkable module, you must call this
function inside the initialisation function given to
Eliom_services.register_eliom_module.
val get_site_dir : sp:server_params -> Ocsigen_lib.url_pathval get_config_default_charset : sp:server_params -> stringtype 'a volatile_table
val create_volatile_table : ?sp:server_params -> unit -> 'a volatile_table
Warning: If you use that function after the initialization phase,
you must give the ~sp parameter, otherwise it will raise the exception
Eliom_common.Eliom_function_forbidden_outside_site_loading.
val get_volatile_session_data : ?session_name:string ->
?secure:bool ->
table:'a volatile_table ->
sp:server_params -> unit -> 'a session_dataval set_volatile_session_data : ?session_name:string ->
?secure:bool ->
table:'a volatile_table ->
sp:server_params -> 'a -> unitval remove_volatile_session_data : ?session_name:string ->
?secure:bool ->
table:'a volatile_table ->
sp:server_params -> unit -> unittype 'a persistent_table
val create_persistent_table : string -> 'a persistent_tableOcsipersist.val get_persistent_session_data : ?session_name:string ->
?secure:bool ->
table:'a persistent_table ->
sp:server_params ->
unit -> 'a session_data Lwt.tval set_persistent_session_data : ?session_name:string ->
?secure:bool ->
table:'a persistent_table ->
sp:server_params -> 'a -> unit Lwt.tval remove_persistent_session_data : ?session_name:string ->
?secure:bool ->
table:'a persistent_table ->
sp:server_params -> unit -> unit Lwt.tval close_session : ?close_group:bool ->
?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unit Lwt.t
Shortcut for Eliom_sessions.close_volatile_data_session followed by
Eliom_sessions.close_service_session and
Eliom_sessions.close_persistent_data_session.
By default will close both secure and unsecure sessions, but
if ~secure is present.
Warning: you may also want to remove some data from the polymorphic
request data table when closing a session
(See Eliom_sessions.get_request_cache).
val close_volatile_session : ?close_group:bool ->
?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unit
Shortcut for Eliom_sessions.close_volatile_data_session followed by
Eliom_sessions.close_service_session.
val close_persistent_data_session : ?close_group:bool ->
?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unit Lwt.tval close_volatile_data_session : ?close_group:bool ->
?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unitval close_service_session : ?close_group:bool ->
?session_name:string ->
?secure:bool -> sp:server_params -> unit -> unitval close_all_sessions : ?close_group:bool ->
?session_name:string ->
?sp:server_params -> unit -> unit Lwt.t?session_name (session name) is not present,
the session with default name is closed.
Warning: If you use this function after the initialisation phase,
you must give the ~sp parameter, otherwise it will raise the
exception Eliom_common.Eliom_function_forbidden_outside_site_loading.
val close_all_volatile_sessions : ?close_group:bool ->
?session_name:string ->
?sp:server_params -> unit -> unit Lwt.t?session_name (session name) is not present,
the session with default name is closed.
Warning: If you use this function after the initialisation phase,
you must give the ~sp parameter, otherwise it will raise the
exception Eliom_common.Eliom_function_forbidden_outside_site_loading.
val close_all_persistent_data_sessions : ?close_group:bool ->
?session_name:string ->
?sp:server_params -> unit -> unit Lwt.t?session_name (session name) is not present,
the session with default name is closed.
Warning: If you use this function after the initialisation phase,
you must give the ~sp parameter, otherwise it will raise the
exception Eliom_common.Eliom_function_forbidden_outside_site_loading.
val close_all_service_sessions : ?close_group:bool ->
?session_name:string ->
?sp:server_params -> unit -> unit Lwt.t?session_name (session name) is not present,
the session with default name is closed.
Warning: If you use this function after the initialisation phase,
you must give the ~sp parameter, otherwise it will raise the
exception Eliom_common.Eliom_function_forbidden_outside_site_loading.
val close_all_volatile_data_sessions : ?close_group:bool ->
?session_name:string ->
?sp:server_params -> unit -> unit Lwt.t?session_name (session name) is not present,
the session with default name is closed.
Warning: If you use this function after the initialisation phase,
you must give the ~sp parameter, otherwise it will raise the
exception Eliom_common.Eliom_function_forbidden_outside_site_loading.
module Session_admin:sig..end
val get_get_params : sp:server_params -> (string * string) listval get_all_current_get_params : sp:server_params -> (string * string) listval get_initial_get_params : sp:server_params -> (string * string) listval get_other_get_params : sp:server_params -> (string * string) listval get_nl_get_params : sp:server_params ->
(string * string) list Ocsigen_lib.String_Table.tval get_persistent_nl_get_params : sp:server_params ->
(string * string) list Ocsigen_lib.String_Table.tval get_nl_post_params : sp:server_params ->
(string * string) list Ocsigen_lib.String_Table.tval get_post_params : sp:server_params -> (string * string) list Lwt.tval get_all_post_params : sp:server_params -> (string * string) listval get_ri : sp:server_params -> Ocsigen_extensions.request_infoval get_config_info : sp:server_params -> Ocsigen_extensions.config_infoval get_request : sp:server_params -> Ocsigen_extensions.requestval get_session_name : sp:server_params -> string optionNone if it is not a session service) : ?session_name:string ->
?secure:bool ->
sp:server_params -> unit -> string option Lwt.tNone is no session is active. : ?session_name:string ->
?secure:bool -> sp:server_params -> unit -> string optionNone is no session is active. : ?session_name:string ->
?secure:bool -> sp:server_params -> unit -> string optionNone is no session is active.val get_si : sp:server_params -> Eliom_common.sess_info