sanjiisan

Untitled

Apr 6th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <?php
  2.  
  3. session_start(); //Inicjalizacja
  4.  
  5. unset($_SESSION['counter']); //Usunięcie sesji pod kluczem counter
  6.  
  7. ?>
  8. <!doctype html>
  9. <html lang="en">
  10. <head>
  11. <meta charset="UTF-8">
  12. <meta name="viewport"
  13. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  14. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  15. <title>Zadanie 1</title>
  16. </head>
  17. <body>
  18. <h1> Sesja wyzerowana </h1>
  19. </body>
  20. </html>
  21. ///
  22. <?php
  23.  
  24. session_start();
  25.  
  26.  
  27. if (isset($_SESSION['counter'])) { //Czy istnieje sesji o kluczu counter
  28. echo 'counter: ' . $_SESSION['counter']; //Pokazuje jej wartość
  29. $_SESSION['counter']++; //Dodaje do countera w sesji wartość 1
  30. } else {
  31. echo 'Brak sesji counter'; //Komunikat gdy brak ciastka
  32. }
  33.  
  34. ?>
  35. <!doctype html>
  36. <html lang="en">
  37. <head>
  38. <meta charset="UTF-8">
  39. <meta name="viewport"
  40. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  41. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  42. <title>Zadanie 1</title>
  43. </head>
  44. <body>
  45. <h1> Wartość wczytana z sesji to: <?php /* tutaj wyświetl wartość wczytaną z sesji */ ?> </h1>
  46. </body>
  47. </html>
  48. ///<?php
  49. session_start();
  50.  
  51. $_SESSION['counter'] = 0; //Ustawiam counter w sesji na 0
  52.  
  53. ?>
  54. <!doctype html>
  55. <html lang="en">
  56. <head>
  57. <meta charset="UTF-8">
  58. <meta name="viewport"
  59. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  60. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  61. <title>Zadanie 1</title>
  62. </head>
  63. <body>
  64. <h1> Sesja ustawiona na początkową wartość </h1>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment