php Sessions

PHP Sessions In Hindi – Sessions In Hindi

PHP

PHP Sessions In HindiSessions In Hindi:- PHP Session Ko Ham Isliye Istemal Karte Hai Ki Information Ko Multiple Pages Mai Store Karva Sake.

Also Read :- PHP Form Handling

PHP Sessions In Hindi

Sessions in PHP in Hindi Ka Matlab Hota Hai Ki Jab Ham Kisi Website Ko Open Karte Hai Tab Se Lekar Jab Tak Website Closed Na Ki Jaye Tab Tak User Ki Information Ko Session Hold Karke Rakhta Hai |

Session Ko Istemal Karne Ke Liye PHP Database Ka Hona Bahut Jarurai Hai Kyoki User Ki Information Session Database Mai Store Karta Hain |

PHP session_start() function in Hindi

Session Ko Start Karne Ke Liye PHP Main session_start() Function Ka Istemal Kiya Jata Hain And Session Ko Set Karne Ke Liye PHP superglobals Variable $_SESSION Ka Istemal Kiya Jata Hain |

HTML Tag Se Pahle session_start() Ko Call Karna Bahut Jaruri Hota Hain Or Ise Aap Hamesha HTML Tag Se Pahle Hi Start Kare |

Example_1.php:

<?php
  // start a session
  session_start()
  ?>
  <!DOCTYPE html>
<html>
<body>

<?php
// Set session variables
$_SESSION["user"] = "Danish Ali";
$_SESSION["value"] = "MasterPrograming.com";
echo "Session variables are set in Your Browser.";
?>

</body>
</html>

Output:

Session variables are set in Your Browser.

GET Session Variable Value In Hindi

Jab Hamne Example_1.php Session Ke Data Ko Example_2.php File Me Infomation Access Karne Wale Hai |

Example_1.php Ke Session Ko Ham Isliye Access Kar Sakte Hain Kyoki $_SESSION Global Variable Hai |

Example_2.php

<?php
session_start();
?>
<!DOCTYPE html>
<html>
  <body>

    <?php
  // access previous Example_1.php Variable Name 
      echo "User Name : " . $_SESSION["user"] . ".<br>";
      echo "Your Value : " . $_SESSION["value"] . ".";
    ?>

  </body>
</html>

Output:

User Name : Danish Ali.
Your Value : MasterPrograming.com.

Waise PHP Main Ek OR Tarika Hain $_SESSION Value Ko Show Karna Ka. Niche Diye Example Mai Aap Us Tarike Ko Bhi Dekh Sakte Hain |

Is Method Mai Ham print_r() Function Ka Istemal Karenge Jo Array Ke Return Karta Hain |

Example_2.php

<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>

<?php
print_r($_SESSION);
?>

</body>
</html>

Output:

Array ( [user] => Danish Ali [value] => MasterPrograming.com )

PHP Destroy Session In Hindi

Sessions Ko Destroy Karne Ke Liye session_destroy() Function Ka Istemal Kiya Jata Hain. Lekin Agar Keval Session Variable Ko Remove Karna Hoto Uske Liye session_unset() Function Ka Istemal kiya Jata Hain |

Example:

<?php
session_start();
?>
<!DOCTYPE html>
<html>
  <body>

    <?php
      // remove all session variables
      session_unset();

      // destroy the session
      session_destroy();
    ?>

  </body>
</html>

Output:

// nothing will show

Yadi Aapne  HTML Full Course  And CSS Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

Leave a Reply

Your email address will not be published. Required fields are marked *