phpgt / session
封装用户会话。
v1.2.1
2023-05-25 13:15 UTC
Requires
- php: >=8.0
- phpgt/typesafegetter: ^1.3
Requires (Dev)
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.1
- squizlabs/php_codesniffer: ^3.7
- dev-master
- v1.2.1
- v1.2.0
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.0
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.0
- v0.0.3
- v0.0.2
- v0.0.1
- dev-dependabot/composer/phpunit/phpunit-10.2.0
- dev-81-type-safety
- dev-dependabot/composer/phpstan/phpstan-0.12.85
- dev-circleci
- dev-test-circle
- dev-30-remove-store
- dev-6-dot-notation
- dev-8-session-store
- dev-4-write-delete
This package is auto-updated.
Last update: 2024-09-19 13:00:30 UTC
README
这个库是一个简单面向对象的替代品,用于 $_SESSION 超全局变量,允许应用程序代码传递封装的 SessionStore
对象,因此代码区域可以访问自己的会话区域,而不需要完全读写访问所有会话变量。
会话使用点符号进行寻址,允许处理会话数据类别。这在处理用户身份验证时特别有用,例如。
示例用法:通过用户名首字母欢迎用户或注销用户
if($session->contains("auth")) { // Remove the *whole* auth section of the session on logout. if($action === "logout") { $session->delete("auth"); } else { // Output a variable within the auth namespace: $message = "Welcome back, " . $session->getString("auth.user.name"); } } else { // Pass the "auth" store to a class, so it // can't read/write to other session variables: AuthenticationSystem::beginLogin($session->getStore("auth")); }