PHP - session_set_cookie_params and session_get_cookie_params

im looking at the sessions a little more and would like some input.

in a simple login form after submitting the form, I have

.
..
...
session_name('TOKEN');
session_set_cookie_params( time() + 600, './', 'example.co.uk', false, false);
session_start();
$_SESSION['TOKEN'] = TOKEN;
...
..
. 

and then when the server request is done, I have this.

.
..
...
session_name('TOKEN');
$session_data = session_get_cookie_params();
print_r($session_data);
...
..
. 

which returns Array ( [lifetime] => 0 [path] => / [domain] => [secure] => [httponly] => )

since you can see that something is not working, or I'm missing something, or I'm going to be a little handful!

In any case, if someone has any data on where I am mistaken, I would like it!

+3
source share
3 answers

You may already understand this, but session_set_cookie_params () needs to be called before session_start () for each request for a separate page. So, say that manual recording is entered for the function.

+4
source

- cookie . .

, session_get_cookie_params . , , , .

0

I think it can work

session_set_cookie_params( time() + 600, '/', '.example.co.uk', false, false);

'/' not './'

'. example.co.uk 'not' example.co.uk '

It worked well for me.

0
source

Source: https://habr.com/ru/post/1741774/


All Articles