Session,cookies and get and post methods


Published on

1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Session,cookies and get and post methods

  1. 1. WELCOME
  2. 2. MIDHUNSUDHAKAR 9995586182 Session and cookies, GET and POST methods
  3. 3. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  4. 4. content •What are session and cookies •How it works •What are GET and POST methods •examples
  5. 5. HTTP •HTTP is a stateless protocol. •Does not remember what happened between two consecutive requests. •Even two Requests made by same user are different for HTTP. •HTTP just processes a client REQUEST and supplies the server RESPONSE.
  6. 6. What is cookie ? •Cookies are small piece of data •Stored in the users computer. •it stores info about you and your preferences.
  7. 7. For example.
  8. 8. It is not limited to remember just our languages. •It can contain time you visited a web site. •Or items in your shopping cart •Or even contain all the links your clicked.
  9. 9. Syntax and example Syn: Setcookie(name, value, expire, path, domain); Ex: setcookie("user", "Alex Porter", time()+3600); click ME
  10. 10. To Read Cookie Values $_COOKIE['CookieName']; $_REQUEST['CookieName']; To Destroy a cookie setcookie("user", "", time()-3600);
  11. 11. •It is same like cookies •But it stored in the server. •Usually used for handle user info about one session •Default expire time is 24mnts What is session ?
  12. 12. Syntax and example Syn: session_start(); $_SESSION[‘name']=value; Ex: $_SESSION[‘userid']=100;
  13. 13. Accessing session variable $_SESSION['views']; Destroying a Session unset($_SESSION[‘userid']); session_destroy(); click Me
  14. 14. Why GET and POST methods? These are two ways the browser client can send info to the web server.
  15. 15. GET method •It sends only limited amount of data. •Info send using GET method will appear in browser URL •PHP provides $_GET associative array to access info.
  16. 16. example <?php if( $_GET["name"] || $_GET["age"] ) { echo "Welcome ". $_GET['name']. "<br />"; echo "You are ". $_GET['age']. " years old."; } ?> <html> <body> <form action="<?php $_PHP_SELF ?>" method="GET"> Name: <input type="text" name="name" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body> </html> clickME
  17. 17. POST method • info sent by using POST method is not visible to users. •does not have any restriction on data size to be sent. •PHP provides $_POST associative array to access
  18. 18. example <?php if( $_POST["yourname"] || $_POST["yourage"] ) { echo "Welcome ". $_POST['yourname']. "<br />"; echo "You age is ". $_POST['yourage']. " years."; exit(); } ?> <html> <body> <form action="<?php $_PHP_SELF ?>" method="POST"> Your Name: <input type="text" name="yourname" /> Your Age: <input type="text" name="yourage" /> <input type="submit" /> </form> </body> </html> click ME
  19. 19. THANK YOU
  20. 20. Want to learn more about programming or Looking to become a good programmer? Are you wasting time on searching so many contents online? Do you want to learn things quickly? Tired of spending huge amount of money to become a Software professional? Do an online course @ We put industry standards to practice. Our structured, activity based courses are so designed to make a quick, good software professional out of anybody who holds a passion for coding.
  21. 21. Follow us @ Like us @ Subscribe to us @ Become a follower @ Connect to us @ Give a feedback @ Thanks in advance | |
  22. 22. Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Cafit Square, Hilite Business Park, Near Pantheerankavu, Kozhikode Start up Village Eranakulam, Kerala, India. Email: Contact Us