How TP5 uses cookie? in validation classes

if you add public $uid=Cookie::get ("uid") to the validation class like this, you will report an error. Why do you report an error? Can"t you use cookie like this?

<?php
namespace app\index\validate;

use think\Validate;
use think\facade\Cookie;

class User extends Validate
{
    public $uid=Cookie::get("uid");
    protected $rule =   [
        "uid"   => "number|between:1,120",
    ];
}

Mar.19,2021

Class attribute defaults can only use constants.
you can set $uid in the constructor.
but pay attention to the problem of overriding the parent constructor.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5efaf-59d7c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5efaf-59d7c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?