diff --git a/admin.php b/admin.php index b6c32eb..11abc6b 100644 --- a/admin.php +++ b/admin.php @@ -8,10 +8,10 @@ foreach (glob('components/admin/*.php') as $file) include_once 'components/head.php'; -if (!isset($_COOKIE['role_id'])) +if (!isset($_SESSION['role_id'])) header('Location: user.php'); -else if ($_COOKIE['role_id'] >= 3) - header('Location: user.php?action=view&user_id=' . $_COOKIE['user_id']); +else if ($_SESSION['role_id'] >= 3) + header('Location: user.php?action=view&user_id=' . $_SESSION['user_id']); include_once 'functions/admin_functions.php'; diff --git a/articles.php b/articles.php index 40b4fda..8c02db3 100644 --- a/articles.php +++ b/articles.php @@ -21,7 +21,7 @@ if (isset($_POST['form_id'])) { update_article($_POST['article_id'], $_POST['title'], $_POST['excerpt'], $tags, $_POST['markdown']); header('Location: articles.php?article_id=' . $_POST['article_id']); } else { - $id = create_article($_COOKIE['user_id'], $_POST['title'], $_POST['excerpt'], (isset($_POST['tags']) ? $_POST['tags'] : []), $_POST['markdown']); + $id = create_article($_SESSION['user_id'], $_POST['title'], $_POST['excerpt'], (isset($_POST['tags']) ? $_POST['tags'] : []), $_POST['markdown']); header('Location: articles.php?article_id=' . $id); } @@ -50,7 +50,7 @@ if (isset($_POST['form_id'])) { echo article_list(article_ids_by_newest()); break; case 'read': - if (isset($_COOKIE['user_id']) && isset($_GET['article_id'])) { + if (isset($_SESSION['user_id']) && isset($_GET['article_id'])) { increment_read_counter($_GET['article_id']); echo article_page_from_markdown($_GET['article_id']); } else { @@ -67,7 +67,7 @@ if (isset($_POST['form_id'])) { } } -if (($view == 'list' || $view == 'sort') && (isset($_COOKIE['role_id']) && $_COOKIE['role_id'] <= 3)) { +if (($view == 'list' || $view == 'sort') && (isset($_SESSION['role_id']) && $_SESSION['role_id'] <= 3)) { echo '
diff --git a/components/article/article.php b/components/article/article.php index 6eaa64f..8c3e66a 100644 --- a/components/article/article.php +++ b/components/article/article.php @@ -18,7 +18,7 @@ function article_page_from_markdown($article_id)

' . $article['title'] . '

- ' . (isset($_COOKIE['user_id']) && $_COOKIE['user_id'] == $article['author_id'] ? '' : '') . ' + ' . (isset($_SESSION['user_id']) && $_SESSION['user_id'] == $article['author_id'] ? '' : '') . '
diff --git a/components/nav.php b/components/nav.php index b17a533..8fafb3f 100644 --- a/components/nav.php +++ b/components/nav.php @@ -9,15 +9,15 @@ $nav = '
  • Articles
  • '; -if (isset($_COOKIE['role_id']) && $_COOKIE['role_id'] <= 2) { - $nav .= ' +if (isset($_SESSION['role_id']) && $_SESSION['role_id'] <= 2) { + $nav .= '
  • Admin
  • '; } -if (isset($_COOKIE['user_id'])) { - $nav .= ' -
  • Account
  • +if (isset($_SESSION['user_id'])) { + $nav .= ' +
  • Account
  • '; } @@ -30,21 +30,21 @@ $nav .= ' $theme_toggle = ''; if ($_SESSION['theme'] == 'dark') - $theme_toggle = 'light'; + $theme_toggle = 'light'; else - $theme_toggle = 'dark'; + $theme_toggle = 'dark'; $nav .= ' '; -if (isset($_COOKIE['username'])) { - $nav .= ' +if (isset($_SESSION['username'])) { + $nav .= ' Log Out '; } else { - $nav .= ' + $nav .= ' Login Sign Up '; diff --git a/components/user/request_role_change.php b/components/user/request_role_change.php index 769c694..400e65f 100644 --- a/components/user/request_role_change.php +++ b/components/user/request_role_change.php @@ -8,7 +8,7 @@ function request_role_change_form() while ($row = $result->fetch_assoc()) { $roles .= ' '; diff --git a/components/user/user_view.php b/components/user/user_view.php index 89c4efb..199ab17 100644 --- a/components/user/user_view.php +++ b/components/user/user_view.php @@ -19,7 +19,7 @@ function user_view($user_id) // TODO: Allow user to update profile picture. // // - if ((isset($_COOKIE['user_id']) && $_COOKIE['user_id'] == $user_id) || (isset($_COOKIE['role_id']) && $_COOKIE['role_id'] <= 2)) { + if ((isset($_SESSION['user_id']) && $_SESSION['user_id'] == $user_id) || (isset($_SESSION['role_id']) && $_SESSION['role_id'] <= 2)) { $view .= '

    User Actions