Session
Session : 4D.Session
| Parâmetro | Tipo | Descrição | |
|---|---|---|---|
| Resultado | 4D. Session | ← | Objecto Session |
História
| Release | Mudanças |
|---|---|
| 20 R8 | Support of standalone sessions |
| 20 R5 | Suporte a sessões de procedimento armazenado e cliente remoto |
| 18 R6 | Adicionado |
Descrição
The Session command returns the Session object corresponding to the current session.
Depending on the process from which the command is called, the current session can be:
- uma sessão web (quando sessões escaláveis são ativadas),
- a remote user session (on the server),
- a stored procedures session,
- a standalone session.
Para obter mais informações, consulte Tipos de sessão.
The command returns Null if:
- it is called in a web process and scalable sessions are disabled on the web server,
- it is called on a remote 4D client.
Sessões web
O objeto Session das sessões web está disponível em qualquer processo web:
On Web Authentication,On Web Connection, andOn REST Authenticationdatabase methods,- código processado a través das etiquetas 4D nas páginas semidinâmicas (4DTEXT, 4DHTML, 4DEVAL, 4DSCRIPT/, 4DCODE)
- os métodos projeto com o atributo "Available through 4D tags and URLs (4DACTION...)" e chamados através de 4DACTION/ urls,
On Mobile App AuthenticationandOn Mobile App Actiondatabase methods for mobile requests,- Funções ORDA chamadas com solicitações REST.
Para obter mais informações sobre as sessões dos usuários da web, consulte a seção Sessões de Servidor Web.
Sessões de usuário remoto
The Session object of remote user sessions is available from:
- Métodos de projeto que têm o atributo Execute on Server (são executados no processo "geminado" do processo do cliente),
- Triggers,
- ORDA funções do modelo de dados (exceto aquelas declaradas com a palavra-chave
local, - 'Conexão aberta com o servidor' e 'Conexão com o servidor' métodos de banco de dados.
For more information on remote user sessions, please refer to the Remote user sessions paragraph.
a sessão de procedimentos armazenados
Todos os processos de procedimento armazenado compartilham a mesma sessão de usuário virtual. O objeto Session de procedimentos armazenados está disponível em:
- métodos chamados com o comando
Execute on server, On Server Startup,On Server Shutdown,On Backup Startup,On Backup Shutdown, andOn System eventdatabase methods
For more information on stored procedures virtual user session, please refer to the Stored procedure sessions paragraph.
Sessão autônoma
The Session object is available from any process in standalone (single-user) applications so that you can write and test your client/server code using the Session object in your 4D development environment.
For more information on standalone sessions, please refer to the Standalone sessions paragraph.
Session and components
When Session is called from the code of different components loaded in the project, the command returns an object depending on the calling request and the context:
- in case of a web request,
Sessionalways returns the session attached to the target web server of the request (and not a session of the component's web server), - in case of a remote request executed on the server,
Sessionalways returns the session attached to the remote user, - in case of a stored procedure session or a standalone session,
Sessionalways returns the single current session (the same object is used during all the work session).
Exemplo
You have defined the action_Session method with attribute "Available through 4D tags and URLs". Pode chamar ao método introduzindo a URL abaixo no navegador:
IP:port/4DACTION/action_Session
//action_Session method
Case of
:(Session#Null)
If(Session.hasPrivilege("CreateInvoices")) //calling the hasPrivilege function
WEB SEND TEXT("4DACTION --> Session is CreateInvoices")
Else
WEB SEND TEXT("4DACTION --> Session is not CreateInvoices")
End if
Else
WEB SEND TEXT("4DACTION --> Session is null")
End case
Veja também
Session storage
Session API
Desktop sessions
Web server user sessions
Scalable sessions for advanced web applications (blog post)
Propriedades
| Número de comando | 1714 |
| Thread safe | sim |