03-28-2017, 08:25 PM
hello!
Thank you for writing this cool user management software.
I'm not entirely sure if this is free from bugs, maybe you see something wrong with it but here goes:
In users/includes/navigation.php I've added
And:
(you have to put your domain name where it says example.com)
In users/logout.php at the top:
and a bit lower:
On other pages (in the body) I've added:
The advantage of doing it like this is that beyond logging in and out it doesn't require any php.
One can have completely static html documents that, when logged out displays:
home | login | register | forgot password
While when logged in you get:
home | logout
(The admin page I keep on the bookmarks toolbar)
The point of using static html:
1) you can have a lot of traffic with the server doing very little work.
2) php can beak in countless different ways.
2.1) I hardly ever write php without any mistakes. The html continues to work.
2.2) php is frequently updated, webhosts tend to wait for you to go on vacation then break everything.
2.3) usespice might have a bug in it. (I'm not counting on it but I'd say a non zero chance)
2.4) your database might get corrupted.
2.5) someone might hack your site.
3) static html is amazingly fast
I like to keep things as simple as possible partially because I'm not very good at php, I haven't really looked into all the userspice helper functions and I don't know how to use bootstrap. I could include all that in pages that use only the isloggedin thingy but that, with much love and respect, seems rather silly.
Hope this is useful
Thank you for writing this cool user management software.
I'm not entirely sure if this is free from bugs, maybe you see something wrong with it but here goes:
In users/includes/navigation.php I've added
Code:
<?php if($user->isLoggedIn()){ //anyone is logged in?>
Code:
<script>document.cookie="loggedin=1;path=/;example.com"</script>
And:
Code:
<?php }else{ // no one is logged in so display default items ?>
Code:
<script>document.cookie="loggedin=0;path=/;host=example.com"</script>
(you have to put your domain name where it says example.com)
In users/logout.php at the top:
Code:
setcookie("loggedin","0",time()+500,"/");
and a bit lower:
Code:
$user->logout();
Code:
session_destroy();
On other pages (in the body) I've added:
Code:
<script>
Code:
var sheet = document.createElement('style');
Code:
sheet.innerHTML = document.cookie.indexOf('loggedin=1')!=-1?".out{display:none}":".in{display:none}";
Code:
document.head.appendChild(sheet);
Code:
</script>
Code:
<a href="/">home</a>
Code:
<a href="users/logout.php" class="in">logout</a>
Code:
<span class="out">
Code:
<a href="users/login.php">login</a>
Code:
<a href="users/join.php">register</a>
Code:
<a href="users/forgot_password.php">forgot password</a>
Code:
</span>
The advantage of doing it like this is that beyond logging in and out it doesn't require any php.
One can have completely static html documents that, when logged out displays:
home | login | register | forgot password
While when logged in you get:
home | logout
(The admin page I keep on the bookmarks toolbar)
The point of using static html:
1) you can have a lot of traffic with the server doing very little work.
2) php can beak in countless different ways.
2.1) I hardly ever write php without any mistakes. The html continues to work.
2.2) php is frequently updated, webhosts tend to wait for you to go on vacation then break everything.
2.3) usespice might have a bug in it. (I'm not counting on it but I'd say a non zero chance)
2.4) your database might get corrupted.
2.5) someone might hack your site.
3) static html is amazingly fast
I like to keep things as simple as possible partially because I'm not very good at php, I haven't really looked into all the userspice helper functions and I don't know how to use bootstrap. I could include all that in pages that use only the isloggedin thingy but that, with much love and respect, seems rather silly.
Hope this is useful