我正在尝试解密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 = \GuzzleHttp\Psr7\parse_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): $value\n";
但这也导致有效负载无效。
我如何解密此laravel_session以获得用户会话ID!
我想通过此会话获取Auth用户。
我在堆栈溢出和google中进行了大量搜索,但所有情况都不符合我的情况。
注意:我正在使用SESSION_DRIVER = file
答案 0 :(得分:1)
Laravel提供了一种获取会话ID的方法:
use Illuminate\Support\Facades\Session;
$sessionid = Session::getId();