Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php /* ------------ PHP COMMON OPERATIONS ------------ */
- $max_expiration = time() + 34560000; // (400 * 24 * 60 * 60) = 34560000
- // $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false;
- $cookie_options = array('expires' => $max_expiration, 'path' => '/', 'domain' => '', 'secure' => false, 'httponly' => false, 'samesite' => 'None');
- // $cookie_options = array('expires' => $max_expiration, 'path' => '/', 'domain' => '', 'secure' => false, 'httponly' => false);
- $cookie_options_string = json_encode($cookie_options);
- // $cookie_options_decoded = json_decode($cookie_options_string, true); // I keep that as an exemple to how re-obtain the original array.
- $cookie_value = array(
- 'options' => $cookie_options_string, /* Jesus... */
- 'répondu' => false
- );
- $cookie_value_string = json_encode($cookie_value);
- // setcookie("Sondage01", $cookie_value_string, $cookie_options);
- // $cookie_created = setcookie("Sondage01", $cookie_value_string, $cookie_options);
- // $cookie_created = setcookie("Sondage01", $cookie_value_string, $max_expiration, '/', '', false, false);
- try {
- setcookie("Sondage01", $cookie_value_string, $cookie_options);
- // setcookie("Sondage01", $cookie_value_string, $max_expiration, '/', '', false, false);
- $cookie_return = "Ca semble bon";
- //$_COOKIE["Sondage01"] = $cookie_value_string;
- } catch(Exception $e) {
- // echo "<section>";
- // echo "<p>Impossible d'écrire le cookie.</p>";
- // echo "<p>".$e->getMessage()."</p>";
- // echo "</section>";
- }
- /* ------------------------------------------------- */
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
- <html class="home" style="background-color: #0C051D;">
- <head>
- <meta charset="utf-8">
- <title>TEST</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- </head>
- <body id="top" class="header_scrolled">
- <div id="over_content">
- <?php echo "<p>max_expiration : $max_expiration</p>"; ?>
- <?php echo "<p>cookie_options_string : $cookie_options_string</p>"; ?>
- <?php echo "<p>Cookie creation : $cookie_return</p>"; ?>
- <?php echo "<p>COOKIE content : ".$_COOKIE["Sondage01"]."</p>"; ?>
- </div>
- <div class="content">
- <div class="wrapper">
- <main>
- <section>
- <h1>Page de test</h1>
- <p>Hello world.</p>
- </section>
- </main>
- </div> <!-- Wrapper -->
- <footer id="main_footer" class="main">
- </footer>
- <div class="behind_content">
- </div><!-- .behind_content -->
- </div><!-- .content -->
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment