Skip to content

When $_SERVER['REMOTE_ADDR'] is IPv6 Session::getFromRequest() triggers MySQL error. #153

@hparadiz

Description

@hparadiz

Recently encountered this bug when running a site localhost on my mac. The IP was ::1 but ip2long was giving me a null value so the generated query was invalid.

public static function getFromRequest($create = true)
{
$sessionData = array(
'LastIP' => !empty($_SERVER['REMOTE_ADDR']) ? ip2long($_SERVER['REMOTE_ADDR']) : null
,'LastRequest' => time()
);

image

Considering the architectural challenges with Session data. What do you think about creating a second field for ipv6 addresses?

binary (16) as per this article is suggested: https://medium.com/@richardoosterhof/optimize-php-and-mysql-for-ipv6-daab664962e2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions