负载对于laravel_session解密无效



我试图解密laravel_session,但出现以下错误:

An error has occurred: The payload is invalid.

简单地说,我正在使用Rachet,并试图呼叫授权用户,所以我使用以下方法在httpRequest中获得了cookie:

public function onOpen(ConnectionInterface $conn) {
$this->clients[$conn->resourceId] = new Client();
$this->clients[$conn->resourceId]->conn = $conn;

$cookiesRaw = $conn->httpRequest->getHeader('Cookie');
$cookies = [];
if(count($cookiesRaw))
{
$cookies = GuzzleHttpPsr7parse_header($cookiesRaw)[0]; // Array of cookies
}
// Get the laravel's one
$laravelCookie = $cookies[Config::get('session.cookie')];
$idSession = Crypt::decrypt($laravelCookie);
echo "n cookie is ";
print_r($idSession);
}

Crypt::decrypt($laravelCookie);导致错误,我尝试使用:

$cookie_contents = json_decode( base64_decode( $laravelCookie, true ));
$value = base64_decode( $cookie_contents->value );
$iv = base64_decode( $cookie_contents->iv );
$clear = unserialize( openssl_decrypt($value, Config::get( 'app.cipher' ), Config::get( 'app.key' ), OPENSSL_RAW_DATA, $iv));
echo "Cookie contents (Session ID): $valuen";

但它也导致有效载荷无效。

如何解密此laravel_session以获取用户会话id!

我想通过此会话获取Auth用户。

我在堆栈溢出和谷歌上搜索了很多,但所有的案例都与我的不匹配。

注意:我使用SESSION_DRIVER=文件

Laravel提供了一种获取会话id的方法:

use IlluminateSupportFacadesSession;
$sessionid = Session::getId();

最新更新