Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start(); //Inicjalizacja
- unset($_SESSION['counter']); //Usunięcie sesji pod kluczem counter
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Zadanie 1</title>
- </head>
- <body>
- <h1> Sesja wyzerowana </h1>
- </body>
- </html>
- ///
- <?php
- session_start();
- if (isset($_SESSION['counter'])) { //Czy istnieje sesji o kluczu counter
- echo 'counter: ' . $_SESSION['counter']; //Pokazuje jej wartość
- $_SESSION['counter']++; //Dodaje do countera w sesji wartość 1
- } else {
- echo 'Brak sesji counter'; //Komunikat gdy brak ciastka
- }
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Zadanie 1</title>
- </head>
- <body>
- <h1> Wartość wczytana z sesji to: <?php /* tutaj wyświetl wartość wczytaną z sesji */ ?> </h1>
- </body>
- </html>
- ///<?php
- session_start();
- $_SESSION['counter'] = 0; //Ustawiam counter w sesji na 0
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Zadanie 1</title>
- </head>
- <body>
- <h1> Sesja ustawiona na początkową wartość </h1>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment