BigGrecian Posted January 24, 2013 Share Posted January 24, 2013 Hello all, Really dumb questions. I am recoding a site to PHP and the cookies are set in asp on another page as ("ENROLLER")("COOKIE") In ASP I would <%Request.cookies("ENROLLER")("COOKIE")%> How do I get the specific COOKIE as above in php? Link to comment https://forums.phpfreaks.com/topic/273597-cookies/ Share on other sites More sharing options...
Jessica Posted January 24, 2013 Share Posted January 24, 2013 the superglobal $_COOKIE array contains all cookies. The manual is always a good place to look: http://us1.php.net/cookies Link to comment https://forums.phpfreaks.com/topic/273597-cookies/#findComment-1408017 Share on other sites More sharing options...
BigGrecian Posted January 24, 2013 Author Share Posted January 24, 2013 I have used <?php echo $_COOKIE["ENROLLER"]["SNAME"]?> like ASP would pull them but that doesn't work. <?php echo $_COOKIE["ENROLLER"]?> returns all ENROLLER cookies with & between them. I just want the ENROLLER:SNAME cookie. Link to comment https://forums.phpfreaks.com/topic/273597-cookies/#findComment-1408039 Share on other sites More sharing options...
kicken Posted January 24, 2013 Share Posted January 24, 2013 Dump the $_COOKIE variable using var_dump so you can see for sure what it contains: var_dump($_COOKIE); I'm not too familiar with ASP but it appears as if you're trying to store an array of different cookies under one overall cookie name. You may need to write a function to convert whatever format ASP uses to store the cookies into a compatible PHP structure. Link to comment https://forums.phpfreaks.com/topic/273597-cookies/#findComment-1408064 Share on other sites More sharing options...
BigGrecian Posted January 25, 2013 Author Share Posted January 25, 2013 array(2) { ["ENROLLER"]=> string(205) "ADMIN=3&SCHOOL=0&STUDENTID=119&ATSCHOOL=1&EXAMINER=1&INSTRUCTORID=35&INSTRUCTOR=1&SSIRNAME=Doe&SNAME=John&DURATION=30 Mins&[email protected]&CUSTOMERID=0&CAATESTFEE=1&VISASENT=1&TSAR=1" ["ASPSESSIONIDACBQQTAC"]=> string(24) "DCBLNLMAIJGJPIPJAHLHAJID" } In ASP you can pull the sub COOKIE such as ENROLLER and SSIRNAME or ENROLLER and SNAME. Link to comment https://forums.phpfreaks.com/topic/273597-cookies/#findComment-1408087 Share on other sites More sharing options...
kicken Posted January 25, 2013 Share Posted January 25, 2013 Based on the var_dump, you should be able to just use parse_str to parse the cookie into is sub-cookies. The result can be either stored into a different variable or back into $_COOKIE['ENROLLER']. parse_str($_COOKIE['ENROLLER'], $_COOKIE['ENROLLER']); Link to comment https://forums.phpfreaks.com/topic/273597-cookies/#findComment-1408088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.