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? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 24, 2013 Share Posted January 24, 2013 (edited) the superglobal $_COOKIE array contains all cookies. The manual is always a good place to look: http://us1.php.net/cookies Edited January 24, 2013 by Jessica Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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&SEMAIL=test@email.com&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. Quote Link to comment 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']); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.