Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Browser Persistent Data with PHP Data Persistence on the Web Writing Cookies

Stephen Printup
seal-mask
.a{fill-rule:evenodd;}techdegree
Stephen Printup
UX Design Techdegree Student 45,252 Points

How does the url ?save (extension) operation work in php for saving cookies?

At 4:44 in this video: https://teamtreehouse.com/library/writing-cookies Alena writes a url that ends with ?save and says it saves the cookie. Can one execute operations on server side php folders using this syntax?

1 Answer

Logan R
Logan R
22,989 Points

Hello!

She says that our story is ready to be saved to a cookie. When you click on the anchor, it goes to the page 'inc/cookie.php' with the GET parameter of "save" set. If you take a look at 2:30, the code she is starting to write is where the cookie is actually saved. When she writes the if statement at 2:00, adding the "?save" in the URL triggers that if block. This is because $_GET now contains the key save.

Hope this kind of clears things up!