Proper use of session_set_cookie_params

I am trying to implement a login system with the "remember me" function. This is my login page: http://pastebin.com/q6iK0Mgy . In this, I am trying to extend the session cookie expiration (PHPSESSIONID) using session_set_cookie_params (). But it does not work.

Relevant part of the code: In this case, the inner if () loop is executed, but session_set_cookie_params ('3600') has no effect. I call session_name (), as this should be a requirement for session_set_cookie_params () (according to one of the comments to the php manual)

if ( isset($_POST["submit"]) ) 
 {
     session_name() ;
     echo "calling before checked " ;
     if ( $_POST["remember"] == "on") 
    {
       // extend expiration date of cookie
       session_set_cookie_params('3600');
       echo "<br/>calling after sessions_set_cookie_params" ;
    }
 } 
 require_once("includes/session.php"); //session start ?>

, , . , , session_cookie. ? ?

+3
2

?

, PHP . , , , , .

session_set_cookie_param , session_start. , cookie , . cookie, session_start, .

session_start - . cookie , , - , ... , cookie . , cookie, cookie, . ! cookie , , , ?

, session_set_cookie_param, cookie . , setcookie (session_name(), blah blah blah), php STILL cookie.

, php cookie.

1

, session_id , . http://php.net/session_id ,

. cookie session_id() cookie session_start(), , , .

session_id($_COOKIE[session_name()]);

, 6 , , , , , , , , , - 2 3 ? . -.

+5
+2

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


All Articles