Reputation: 1
I have a problem with PHP. When user is logged in, or session is started, I want to hide div class, which is button "Login".
How can I make this with PHP?
Upvotes: 0
Views: 192
Reputation: 52802
Instead of trying to hide it, never output the div if the session has login information.
I.e. in your template / code that's outputting the HTML, check if the session is present (you'll have to swap user
with whatever key you're storing the valid login under):
<?php
if (empty($_SESSION['user'])):
?>
<div class="login"> ... </div>
<?php
endif;
?>
.. and if you need it in a function:
<?php
function show_login_if_unknown() {
if (empty($_SESSION['user'])) {
echo '<div class="login"> ... </div>'; // or use ?> ... <?php
}
}
Upvotes: 1