how do i check if user is logged on?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cantaladie9
    New Member
    • Jul 2006
    • 3

    how do i check if user is logged on?

    i would like to echo different links on each page depending on if the user is logged on or not,
    e.g "log on" or "register" if they are not and "change style" if they are,
    how do i do this?
    cheers
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi there,

    emm.. am sure every user allowed to login must have an access level assigned.. rite?? well.. then you can forward each user to a specific page based on their access level.. good luck my fren.. :)

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Assuming that you already know how to get the user to login, the following handles your problem.
      [PHP]<?php
      session_start() ;
      /*--------------------------------------------------------------*
      * Check if user is logged in. This check assumes that you have *
      * saved the user's session data (in this case the 'username' *
      * in the $_SESSION after a valid login. *
      *--------------------------------------------------------------*/
      if (!array_key_exi sts('username', $_SESSION)) {
      // User is not logged-in, so display your 'please login' links
      // ............... ............... ........
      }
      else {
      // user is validly logged in, display whatever you want to
      // ............... ............... ............... ...
      }
      ?>[/PHP]

      Ronald :cool:

      Comment

      Working...