Results 1 to 2 of 2

Thread: Invisible/visible include....

  1. #1
    Join Date
    Jun 2004
    Posts
    12

    Invisible/visible include....

    I am making a php project..its made with container with multiple include/require functions (including php pages).

    I need that if visitor has a cookie (from my site) he sees different include, or include is visible only if visitor has cookie in his comp...

    Cookie will be made with loging in...

    If someone has any idea to make this more elegant please help.

  2. #2
    Join Date
    May 2002
    Location
    hoo noes!?!?
    Posts
    713
    Something like this would work:

    PHP Code:
    <?php
    if (isset($_COOKIE["loggedin"]))
      include(
    'validuser.php');
      echo 
    "Welcome " $_COOKIE["user"] . "!<br />";
    else
      include(
    'guest.php');
      echo 
    "Welcome guest!<br />";
    ?>
    You'd need to set the cookie named "loggedin" to something when the user logs in by using the setcookie() function. This is a pretty basic system.

    Remember that using cookies is not a secure way to do this, because anyone could set a cookie. If really need the extra security you'd have to issue each visitor a unique key which is stored in a cookie, and then check that key against the user's logged in data (which would be handled by sessions).

Similar Threads

  1. PHP include - root relative path?
    By web88js in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 04 Oct 2007, 11:59 PM
  2. logo image not shown: PHP include relative root path?
    By web88js in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 04 Oct 2007, 05:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •