PHP - Session Identifier - Security - Stack Overflow
PHP - Session Identifier - Security - Stack Overflow
Ask Question
So I implemented a system
where everytime a user logged
and/or navigated to some other
page within the web-
application, I would generate a
new hash, store it in the
database, and then store it in
the global $_SESSION['id']
variable. I managed to do this,
but now everytime someone
tries to log in from two devices,
the device with the "older"
session is invalid, because the
user_hash changed from the
new device and logs off the
user with an older session.
session-variables
@RaymondNijland although
session hijacking would
normally require malware in
the user's browser when using
TLS and that's really not
something web sites can
easily protect against. If
you're transferring your
session ID over https, it's not
subject to man in the middle
attacks which is the common
form of session hijacking.
– Devon Bessemer May 10,
2017 at 17:04
Sorted by:
1
Answer Highest score (default)
http://blog.teamtreehouse.com
1
/how-to-create-bulletproof-
sessions
https://paragonie.com/blog/201
5/04/fast-track-safe-and-
secure-php-sessions
I managed to do this,
but now everytime
someone tries to log in
from two devices, the
device with the "older"
session is invalid,
because the user_hash
changed from the new
device and logs off the
user with an older
session.
So I implemented a
system where
everytime a user
logged and/or
navigated to some
other page within the
web-application, I
would generate a new
hash, store it in the
database, and then
store it in the global
$_SESSION['id']
variable.
php.ini:
session.save_handler = files
session.use_cookies = 1
session.cookie_secure = 1
session.use_only_cookies = 1
session.cookie_domain = "examp
session.cookie_httponly = 1
session.entropy_length = 32
session.entropy_file = /dev/ur
session.hash_function = sha256
session.hash_bits_per_characte
If storing sessions in a
database please do ensure
that you make your column
names for the session id long
enough, else sessions will
never connect due to
truncation of the session
name.
Add a comment
Your Answer
Sign up or log in
Sign up using Google
Post as a guest
Name
Email
Required, but never shown
An open-source development
paradigm
Featured on Meta
Related
Question feed
STACK OVERFLOW
Questions Help
PRODUCTS
COMPANY
Science Professional
AcceptBusiness
all cookies
API Data