June 18, 20197 yr What is the difference between include and sessions in PHP?? Include makes an outside/other PHP document acts like it's part of the current PHP.Its like including the outside file as itself,it's similar to import for other language,while session is just a superglobal array that can be accessed by anywhere else as long as session_start()is called.So basically what both does is something like connecting all the files together,so what's the difference? Edited June 18, 20197 yr by Cheah Hsun Teik
June 18, 20197 yr Includes are handy when certain things are required in multiple places, navigation is a prime one or database connect. Sessions are exactly that, individual visitors preferences they need to carry around the site with them in order to deliver them personalised information (e.g. shopping cart contents).
Create an account or sign in to comment