Results 1 to 2 of 2

Thread: Admin Panel Cookies - How would I do it?

  1. #1
    Join Date
    Jan 2012

    Admin Panel Cookies - How would I do it?


    I am creating an admin panel for my website. I have heard that it is possible to protect it in the following way:

    Admins (who should be able to access the admin panel) get a certain cookie.
    This cookie then allows them to get into the admin panel when they go to the panel directory.

    When anyone else goes to the panel directory, just gets taken back to the homepage, and doesn't see anything on the panel

    How would I do this?


  2. #2
    Join Date
    Aug 2004
    Typically this is done via PHP session-handling (e.g. starting with the session_start() function, and when the user logs in, add a setting in $_SESSION to indicate whether they are an admin user. Then on your admin-only pages, your logic would be something like:
    PHP Code:
    <?php // this must be the first line: no output of any kind before it
    session start();
    $_SESSION['is_admin'])) {
    header("Location: http://www.example.com/default_landing_page.php");
    // rest of page...
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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