<?php
// Start new or resume existing session.
session_start();
// Add values to the session.
$_SESSION['item_name'] = 'value'; // string
$_SESSION['item_name'] = 0; // int
$_SESSION['item_name'] = 0.0; // float
// Get session values.
$value = $_SESSION['item_name'];
?>
<?php
session_start();
$_SESSION['var'];
?>
<?php
session_start();
echo session_id();
?>
<?php
// Start our session
session_start();
$_SESSION["favcolor"] = "red";
echo $_SESSION["favcolor"]; //red
$_SESSION["favanimal"] = "rabbit";
echo $_SESSION["favanimal"]; //rabbit
?>
session_start();
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$link = new mysqli('localhost', 'username', 'password', 'db_name');
$link->set_charset('utf8mb4'); // always set the charset
$name = $_GET["username"];
$stmt = $link->prepare("SELECT id FROM Users WHERE username=? limit 1");
$stmt->bind_param('s', $name);
$stmt->execute();
$result = $stmt->get_result();
$value = $result->fetch_object();
$_SESSION['myid'] = $value->id;
session_start();
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
$name = $_GET["username"];
$sql = "SELECT 'id' FROM Users WHERE username='$name' limit 1";
$result = mysqli_query($link, $sql);
if ($result !== false) {
$value = mysqli_fetch_field($result);
$_SESSION['myid'] = $value;
}
1
2
3
php session_start();
echo session_id(); // идентификатор сессии
echo session_name(); // имя - PHPSESSID
<form action="login.php" method="post">
Dein Name: <br />
<input type="Text" name="name" />
<input type="Submit" />
</form>
<input type="text" class="form-control" id="firstNameInput" name="firstNameInput"
placeholder="First Name"
value="{{ Session::has('firstName') ? Session::get('firstName') : old('firstNameInput') }}" />