Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
4
Help us understand the problem. What is going on with this article?
@akiinu

ログの出し方メモ

More than 5 years have passed since last update.

WordPressでお問い合わせのサンキューページにCookieを利用したところ不具合が起こったため、どう条件分岐を通ったか確認する

functions.php
<?php
function p($arg) {
    error_log($arg . "\n" , 3, 'そのフォルダ/log/wp.log');
}
function d($arg) {
      ob_start();
            var_dump($arg);
            $log = ob_get_contents();
                    ob_end_clean();
                    return rtrim($log);
}
function pd($arg)
{
      p(d($arg));
} ?>
thanks.php
<?php p("---------------------------------"); ?>
<?php pd($_COOKIE["visited"]);?>
<?php if(isset($_COOKIE["visited"])){
  pd("setted");
  setcookie("visited","",time() - 1800, "/" );
}else{
  pd("not setted");
   header('location: /contact/index');
}
?>
<?php p("---------------------------------"); ?>

ブラウザでthanks.phpをリロードする
その後、

tail -f そのフォルダ/log/wp.log

(ログには関係ないが)

contact.php
<?php setcookie("visited", 1, 0, "/" ); ?>
4
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
4
Help us understand the problem. What is going on with this article?