I have set up for users online but some users showing always online . can you help anyone this my code

zzz.png

<?php
                    if ($Row->logged_in == '0') {
                        if ($Row->last_login != '0000-00-00 00:00:00') {
                            ?>Last Login : <?php
                            echo date('d M Y ,H:i A', strtotime($Row->last_login));
                        } else {
                            echo "<span class='mlm'>Not Online</span>".' <i class="fa fa-circle" aria-hidden="true" style="color:#ddd"></i>';
                        }
                    } else {
                        echo "<span class='mlm'>Online Now</span>".' <i class="fa fa-circle" aria-hidden="true" style="color:#0eaf02"></i>';
                    }

                    ?>

I would put some var_dump's in to help debug. My guess is the variable type is not what you expect on something.

<?php
                    var_dump($Row);
                    if ($Row->logged_in == '0') {
                        var_dump('condition 3 fired');
                        if ($Row->last_login != '0000-00-00 00:00:00') {
                            var_dump('condition 1 fired');
                            ?>Last Login : <?php
                            echo date('d M Y ,H:i A', strtotime($Row->last_login));
                        } else {
                            var_dump('condition 2 fired');
                            echo "<span class='mlm'>Not Online</span>".' <i class="fa fa-circle" aria-hidden="true" style="color:#ddd"></i>';
                        }
                    } else {
                        var_dump('condition 4 fired');
                        echo "<span class='mlm'>Online Now</span>".' <i class="fa fa-circle" aria-hidden="true" style="color:#0eaf02"></i>';
                    }
                    ?>

Thanks for your reply. seems not working

Sir showing ["logged_in"]=> string(1)

Please help me about this problem . still am waitng for this solution

That conditional is working then.

Is your SQL query selecting the last_login column?

SELECT logged_in, last_login FROM table

The variable $Row should also have the last_login data in it

It will be difficult for you to monitor active users with just database flag as most people can just hit the browser close button to exit or even goto another site using the browser's address bar.

So the best thing will be using sessions. Write some snippets of code for session start to flag up online users as well as another snippets of code for session end to flag up offline users.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.