Displaying objects based on if a user is logged in or not

Posted by MaxMackie on Stack Overflow See other posts from Stack Overflow or by MaxMackie
Published on 2011-11-18T01:20:29Z Indexed on 2011/11/18 1:50 UTC
Read the original article Hit count: 177

Filed under:
|
|

I'm learning about PHP sessions for user authentication on my website. I know how to restrict the viewing of a complete page using sessions (simply check if the 'uid' session variable is set and if it is, show content, if not redirect to an error).

However I'm trying to figure out the best way to selectively show and hide different objects (div, text, images) based on if a user is logged in or not. Is it as simple as checking for the 'uid' session variable and displaying based on if it set or not? Is there a more efficient way of doing this id there are a lot of conditional elements on a page?

© Stack Overflow or respective owner

Related posts about php

Related posts about html