幾乎整天我都在爲這個問題而苦苦掙扎。解析curl_exec響應
我使用$result = curl_exec($ch);
讀取響應,我想獲得set-cookie頭看起來像:
Set-Cookie: JSESSIONID=05a0c785d8e2f4856a3f844e3694; Path=/qos; HttpOnly rememberMe=deleteMe; Path=/qos; Max-Age=0; Expires=Thu, 06-Sep-2012 10:50:20 GMT rememberMe=x+8X9hDZEUwM23osStzBmHs6FV/4VJAy18j4gjswG0H9wYKtOsSLu4p4XQ2KjLReNN4V2NokyjT66QkWzYetsde /Gbvmb9iJgV3VsuCvRgFpEFsduig5wHwu0YXjVgQWheiK87+5CNQE1X06z8mbPKu2GZUE/vwUUraR66ZAfxPdRKM24NKJ7HV4UIAPspudvCTJzFRqfkwb+pw cqnslyB6Rb/LB+pqHx2oshnINTwNd1E25+Zjs8qGQFQnHRvI4mRGF+BHC1JPGBV2GD9F7K29+szUlAGJhKr7FtOV1ELhN4JMqP4yuGDH0Dt9naLbRr6oFxxB 9t1+N5gHKVOE0vL5VM54Is5nAnWmhUrx9r3+R99We5phw7XuE1svlcOq2XrVeRJthMy3Xfp70cobUBdN/bOh5/ih9/wg3XwpagsGUKf1raP9mGO4ShDd+NFg8Z+eC+80Yt2wkS+7ZH/UGNh73LkdtCv6WlgFqiB/po20Lu+gCbDEceKt+lTNlU2c1; Path=/qos; Max-Age=15724800; Expires=Fri, 08-Mar-2013 10:50:20 GMT; HttpOnly
我想他們分裂「;」焦炭。
編輯:
下面的解決方案沒有按我的想象工作。也許是因爲我有我的resoult其他標題:
Status Code: 200 OK
Content-Length: 0
Date: Fri, 07 Sep 2012 10:50:20 GMT
Server: GlassFish Server Open Source Edition 3.1.1
Set-Cookie: JSESSIONID=05a0c785d8e2f4856a3f844e3694; Path=/qos; HttpOnly rememberMe=deleteMe; Path=/qos; Max-Age=0; Expires=Thu, 06-Sep-2012 10:50:20 GMT rememberMe=x+8X9hDZEUwM23osStzBmHs6FV/4VJAy18j4gjswG0H9wYKtOsSLu4p4XQ2KjLReNN4V2NokyjT66QkWzYetsde /Gbvmb9iJgV3VsuCvRgFpEFsduig5wHwu0YXjVgQWheiK87+5CNQE1X06z8mbPKu2GZUE/vwUUraR66ZAfxPdRKM24NKJ7HV4UIAPspudvCTJzFRqfkwb+pw cqnslyB6Rb/LB+pqHx2oshnINTwNd1E25+Zjs8qGQFQnHRvI4mRGF+BHC1JPGBV2GD9F7K29+szUlAGJhKr7FtOV1ELhN4JMqP4yuGDH0Dt9naLbRr6oFxxB 9t1+N5gHKVOE0vL5VM54Is5nAnWmhUrx9r3+R99We5phw7XuE1svlcOq2XrVeRJthMy3Xfp70cobUBdN/bOh5/ih9/wg3XwpagsGUKf1raP9mGO4ShDd+NFg8Z+eC+80Yt2wkS+7ZH/UGNh73LkdtCv6WlgFqiB/po20Lu+gCbDEceKt+lTNlU2c1; Path=/qos; Max-Age=15724800; Expires=Fri, 08-Mar-2013 10:50:20 GMT; HttpOnly
而我只需要設置Cookie
感謝您的幫助,我解決了它併發布了我的答案:) – dargod