WELCOME
MIDHUNSUDHAKAR
midhusudhakaran@gmail.com
Midhun.sudhakar.73@facebook.com
twitter.com/midhunopus
in.linkedin.com/pub/midhunsudhakar/86/a65/a9b/Phonenumber
9995586182
Session and cookies, GET and POST methods
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
content
•What are session and cookies
•How it works
•What are GET and POST methods
•examples
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.
What is
cookie ?
•Cookies are small piece of data
•Stored in the users computer.
•it stores info about you and your
preferences.
For example.
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.
Syntax and example
Syn:
Setcookie(name, value, expire, path, domain);
Ex:
setcookie("user", "Alex Porter", time()+3600);
click ME
To Read Cookie Values
$_COOKIE['CookieName'];
$_REQUEST['CookieName'];
To Destroy a cookie
setcookie("user", "", time()-3600);
•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 ?
Syntax and example
Syn:
session_start();
$_SESSION[‘name']=value;
Ex:
$_SESSION[‘userid']=100;
Accessing session variable
$_SESSION['views'];
Destroying a Session
unset($_SESSION[‘userid']);
session_destroy();
click Me
Why GET and POST methods?
These are two ways the browser client can send
info to the web server.
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.
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
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
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
THANK YOU
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
@ baabtra.com
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.
Follow us @ twitter.com/baabtra
Like us @ facebook.com/baabtra
Subscribe to us @ youtube.com/baabtra
Become a follower @ slideshare.net/BaabtraMentoringPartner
Connect to us @ in.linkedin.com/in/baabtra
Give a feedback @ massbaab.com/baabtra
Thanks in advance
www.baabtra.com | www.massbaab.com |www.baabte.com
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: info@baabtra.com
Contact Us

Session,cookies and get and post methods

  • 2.
  • 3.
  • 4.
    Disclaimer: This presentationis 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
  • 5.
    content •What are sessionand cookies •How it works •What are GET and POST methods •examples
  • 6.
    HTTP •HTTP is astateless 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.
  • 7.
    What is cookie ? •Cookiesare small piece of data •Stored in the users computer. •it stores info about you and your preferences.
  • 8.
  • 11.
    It is notlimited 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.
  • 12.
    Syntax and example Syn: Setcookie(name,value, expire, path, domain); Ex: setcookie("user", "Alex Porter", time()+3600); click ME
  • 13.
    To Read CookieValues $_COOKIE['CookieName']; $_REQUEST['CookieName']; To Destroy a cookie setcookie("user", "", time()-3600);
  • 14.
    •It is samelike cookies •But it stored in the server. •Usually used for handle user info about one session •Default expire time is 24mnts What is session ?
  • 15.
  • 16.
    Accessing session variable $_SESSION['views']; Destroyinga Session unset($_SESSION[‘userid']); session_destroy(); click Me
  • 17.
    Why GET andPOST methods? These are two ways the browser client can send info to the web server.
  • 18.
    GET method •It sendsonly limited amount of data. •Info send using GET method will appear in browser URL •PHP provides $_GET associative array to access info.
  • 19.
    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
  • 20.
    POST method • infosent 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
  • 21.
    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
  • 22.
  • 23.
    Want to learnmore 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 @ baabtra.com 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.
  • 24.
    Follow us @twitter.com/baabtra Like us @ facebook.com/baabtra Subscribe to us @ youtube.com/baabtra Become a follower @ slideshare.net/BaabtraMentoringPartner Connect to us @ in.linkedin.com/in/baabtra Give a feedback @ massbaab.com/baabtra Thanks in advance www.baabtra.com | www.massbaab.com |www.baabte.com
  • 25.
    Emarald Mall (BigBazar 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: info@baabtra.com Contact Us