Case Study -PHP Coding series 1 - Explain concept of session - TopicsExpress



          

Case Study -PHP Coding series 1 - Explain concept of session s? Difficulty- Easy Time - 15 Minutes Audience - Beginners . We already have seen $_POST , $_GET , etc methods inside php …. Typically they collect variables from elsewhere ,sometimes from forms ,sometimes from other inout elements . The mode of storage is like that of associative arrays with syntax like $_POST[name]= $_name1 ...where the name is the variable(or the index ) , the value captured via the method (post )is stored inside this index and is stored in PHP normal variable name 1 Now , see this syntax $_SESSION [name] = Amlan....obviously , it implies that the session variable name has a value of Amlan inside it . So what is so special about defining a session variable . This can be used elsewhere also on the project files (provided session has been initialised before making use of the session variables ) Thus ,Session are also superglobal arrays and the values stored inside them get stored on the server . What this implies is if i store session variable somewhere , i can use the session variable elsewhere as well , but only point i need to take care of is that the session by itself must be initialized in the page for all session variables to be alive . When you login to a site , you my note how the site usage gets customised as per your entry ....for example when you log into facebook, you log in and thus a session id is created in your name ...now when you surf albums , play games etc ,continue some activities from where you left last ----this all is possible because of sessions because the imprint of the user is stored inside the server from the session id . We can unset specific sessions for a specific session variable by using unset function or (2)in case we wanna destroy all session variables , that can be easily done as well by destroy session function(using destroy session will destroy all session variables set ) Hopefully that helps , Cheers , Amlan Dutta
Posted on: Fri, 25 Oct 2013 03:13:16 +0000

Trending Topics



Recently Viewed Topics




© 2015