Reputation: 1
echo $cookie[4];
Result:
#HttpOnly_bacohuracm FALSE / TRUE 0 PHPSESSID 3A8DB8BE067954EE327A56F7F8D8B19C
I want to delete this part:
#HttpOnly_bacohuracm FALSE / TRUE 0 PHPSESSID
and get only this part:
3A8DB8BE067954EE327A56F7F8D8B19C
I tried preg_match()
, it has given a null
result. I tried some other ways, and got the same null
result and still couldn't figure out how I can do this job with PHP.
Upvotes: -1
Views: 100
Reputation: 301
To return only what you're looking for:
$source = "#HttpOnly_bacohuracm FALSE / TRUE 0 PHPSESSID 3A8DB8BE067954EE327A56F7F8D8B19C";
preg_match("/PHPSESSID (\w+)$/", $source, $matches);
print $matches[1];
If this still returns null, is error text being suppressed? Is there anything related in the logs?
Upvotes: 0
Reputation: 8306
foreach($cookie as $value)
echo substr($value, strpos($value, 'PHPSESSID')+10);
Would work
Upvotes: 2