Browse Source

Merge pull request #457 from ProjectPatatoe/cookie

Quick Cookie Improvement by @ProjectPatatoe
pull/463/head
Dan 4 years ago
committed by GitHub
parent
commit
7493400b10
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 3 deletions
  1. +1
    -1
      install.php
  2. +2
    -0
      system/admin/admin.php
  3. +1
    -0
      system/htmly.php
  4. +4
    -2
      system/includes/session.php

+ 1
- 1
install.php View File

@ -222,7 +222,7 @@ if(from($_SERVER,'QUERY_STRING') == "rewriteRule.html")
echo "YES!";
die();
}
session_set_cookie_params(['samesite' => 'Strict']);
session_start();
new Settings;


+ 2
- 0
system/admin/admin.php View File

@ -53,6 +53,7 @@ function session($user, $pass)
if ($user_enc == "password_hash") {
if (password_verify($pass, $user_pass)) {
if (session_status() == PHP_SESSION_NONE) session_start();
if (password_needs_rehash($user_pass, PASSWORD_DEFAULT)) {
update_user($user, $pass, $user_role);
}
@ -62,6 +63,7 @@ function session($user, $pass)
return $str = '<div class="error-message"><ul><li class="alert alert-danger">ERROR: Invalid username or password.</li></li></div>';
}
} else if (old_password_verify($pass, $user_enc, $user_pass)) {
if (session_status() == PHP_SESSION_NONE) session_start();
update_user($user, $pass, $user_role);
$_SESSION[config("site.url")]['user'] = $user;
header('location: admin');


+ 1
- 0
system/htmly.php View File

@ -2648,6 +2648,7 @@ get('/:static', function ($static) {
}
die;
} elseif ($static === 'login') {
if (session_status() == PHP_SESSION_NONE) session_start();
config('views.root', 'system/admin/views');
render('login', array(
'title' => 'Login - ' . blog_title(),


+ 4
- 2
system/includes/session.php View File

@ -1,9 +1,11 @@
<?php
session_start();
session_set_cookie_params(['samesite' => 'Strict']);
if (isset($_COOKIE['PHPSESSID']))
session_start();
function login()
{
if (session_status() == PHP_SESSION_NONE) return false;
if (isset($_SESSION[config("site.url")]['user']) && !empty($_SESSION[config("site.url")]['user'])) {
return true;
} else {


Loading…
Cancel
Save