Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
1b7714d2
Commit
1b7714d2
authored
2 months ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
adjust session handling so that it corresponds to the previous behaviour, fixes #5038
Closes #5038 Merge request
studip/studip!3791
parent
5eecc9a1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/cronjobs/session_gc.php
+1
-1
1 addition, 1 deletion
lib/cronjobs/session_gc.php
lib/session/Manager.php
+31
-15
31 additions, 15 deletions
lib/session/Manager.php
with
32 additions
and
16 deletions
lib/cronjobs/session_gc.php
+
1
−
1
View file @
1b7714d2
...
@@ -22,6 +22,6 @@ class SessionGcJob extends CronJob
...
@@ -22,6 +22,6 @@ class SessionGcJob extends CronJob
public
function
execute
(
$last_result
,
$parameters
=
[])
public
function
execute
(
$last_result
,
$parameters
=
[])
{
{
return
sess
()
->
doGarbageCollect
();
sess
()
->
doGarbageCollect
();
}
}
}
}
This diff is collapsed.
Click to expand it.
lib/session/Manager.php
+
31
−
15
View file @
1b7714d2
...
@@ -11,7 +11,6 @@
...
@@ -11,7 +11,6 @@
*/
*/
namespace
Studip\Session
;
namespace
Studip\Session
;
class
Manager
class
Manager
{
{
public
const
STATE_UNKNOWN
=
false
;
public
const
STATE_UNKNOWN
=
false
;
...
@@ -53,21 +52,23 @@ class Manager
...
@@ -53,21 +52,23 @@ class Manager
{
{
if
(
!
$this
->
isStarted
())
{
if
(
!
$this
->
isStarted
())
{
ini_set
(
'session.use_strict_mode'
,
1
);
ini_set
(
'session.use_strict_mode'
,
1
);
$current
=
session_get_cookie_params
();
$lifetime
=
(
int
)
(
$this
->
options
[
'lifetime'
]
?:
$current
[
'lifetime'
]);
session_set_cookie_params
([
$path
=
$this
->
options
[
'path'
]
?:
$current
[
'path'
];
'lifetime'
=>
0
,
$domain
=
$this
->
options
[
'domain'
]
?:
$current
[
'domain'
];
'path'
=>
$this
->
getCookieParam
(
'path'
),
$samesite
=
$this
->
options
[
'samesite'
]
?:
$current
[
'samesite'
];
'domain'
=>
$this
->
getCookieParam
(
'domain'
),
$secure
=
(
bool
)
$this
->
options
[
'secure'
];
'secure'
=>
(
bool
)
$this
->
getCookieParam
(
'secure'
,
false
),
$httponly
=
(
bool
)
$this
->
options
[
'httponly'
];
'samesite'
=>
$this
->
getCookieParam
(
'samesite'
),
'httponly'
=>
(
bool
)
$this
->
getCookieParam
(
'httponly'
,
false
),
]);
session_set_cookie_params
(
compact
(
'lifetime'
,
'path'
,
'domain'
,
'secure'
,
'samesite'
,
'httponly'
));
session_name
(
$this
->
options
[
'name'
]);
session_name
(
$this
->
options
[
'name'
]);
session_cache_limiter
(
'nocache'
);
session_cache_limiter
(
'nocache'
);
session_set_save_handler
(
$this
->
handler
,
true
);
session_set_save_handler
(
$this
->
handler
,
true
);
session_start
();
session_start
([
'gc_maxlifetime'
=>
(
int
)
$this
->
getCookieParam
(
'lifetime'
),
]);
}
}
}
}
...
@@ -103,6 +104,25 @@ class Manager
...
@@ -103,6 +104,25 @@ class Manager
return
$this
->
options
[
'name'
];
return
$this
->
options
[
'name'
];
}
}
/**
* Returns the value for the given cookie parameter. The value is taken
* from the configured options array (or from the current session
* configuration in php).
*
* If no value is found, null is retuned.
*/
public
function
getCookieParam
(
string
$key
,
bool
$from_config
=
true
):
mixed
{
$value
=
$this
->
options
[
$key
]
??
null
;
if
(
$from_config
)
{
$current
=
session_get_cookie_params
();
$value
=
$value
?:
$current
[
$key
]
??
null
;
}
return
$value
;
}
public
function
destroy
():
void
public
function
destroy
():
void
{
{
if
(
!
$this
->
isStarted
())
{
if
(
!
$this
->
isStarted
())
{
...
@@ -174,12 +194,8 @@ class Manager
...
@@ -174,12 +194,8 @@ class Manager
/**
/**
* returns a SessionDecoder object containing the session variables
* returns a SessionDecoder object containing the session variables
* for the given session id
* for the given session id
*
* @static
* @param string $sid a session id
* @return \SessionDecoder
*/
*/
public
function
getSessionVars
(
$sid
):
\SessionDecoder
public
function
getSessionVars
(
string
$sid
):
\SessionDecoder
{
{
$data
=
$this
->
handler
->
read
(
$sid
);
$data
=
$this
->
handler
->
read
(
$sid
);
return
new
\SessionDecoder
(
$data
);
return
new
\SessionDecoder
(
$data
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment