Jump to content

samesite: warning too much params.


BrainPill
 Share

Recommended Posts

 

I want to set a cookie in a proper way.
So I want to add samesite strict.
When I try to add it with : session_set_cookie_params() at the last parameter (6th) it says :
Warning: session_set_cookie_params() expects at most 5 parameters, 6 given in

example:

    <?php 

    session_set_cookie_params(3600,'','',FALSE, TRUE,'strict');
    ?>

 

How can I add samesite in session_set_cookie_params() ?

 

 

Link to comment
Share on other sites

14 hours ago, justsomeguy said:

 

I tried this:

        <?php 
        $options = array('lifetime => 3600','samesite=>strict');
        session_set_cookie_params($options);

        ?>

but I get the following error:

( ! ) Notice: Array to string conversion in 

does this indicate that you have to read them out with foreach? 

The reason I ask this, is because all the other params could just be put into the session_set_cookie_params() function but this specific one not.

This makes it an exception to the rule.

 

 

 

Link to comment
Share on other sites

You array is not being properly defined as associative. Its currently an array with 2 elements of strings. You need to move the quotes.

<?php
$options = array(
  'lifetime' => 3600,
  'samesite' => 'strict'
);
?>

 

Link to comment
Share on other sites

On 5/2/2019 at 11:24 PM, Funce said:

You array is not being properly defined as associative. Its currently an array with 2 elements of strings. You need to move the quotes.


<?php
$options = array(
  'lifetime' => 3600,
  'samesite' => 'strict'
);
?>

 

okay I fixed that now.

But I the array to string error is still there.

How to solve this?

 

 

Link to comment
Share on other sites

On 5/2/2019 at 7:15 PM, justsomeguy said:

According to the notes in the manual, the options array was added in version 7.3.  If you don't have that then you won't be able to use samesite for this.

I see that now. I have version 7.1.9 so it couldn't work.

 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...