Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a user modify a PHP session?

Tags:

php

Page1.php:

<?php
session_start();
if ($_POST['password'] == "testpass")
    $_SESSION['authenticated'] = true;
?>

Page2.php

<?php
session_start();
if (isset($_SESSION['authenticated']) && $_SESSION['authenticated'] == true) {
    echo "Super secret stuff!";
}
?>

Can a user get in without the super secure password?

like image 695
BronzeByte Avatar asked Dec 29 '11 12:12

BronzeByte


People also ask

Can a user change session variables?

The $_SESSION is stored entirely on the server, so the user cannot modify it.

Can sessions be modified?

No. The data in the $_SESSION variable is stored on the server, inaccessible from the user. A session is coupled to a user through a cookie.

Can PHP session be hacked?

Sessions are NOT serverside, they are stored on the clients local machine (you can go in your cookies and look for a cookie called phpssid under your domain name). Yes they can be hacked, and this is in fact a very common method of hacking.


2 Answers

No. The data in the $_SESSION variable is stored on the server, inaccessible from the user.

A session is coupled to a user through a cookie. A cookie with a identifier (i.e. a long random string) is sent to the user to identify the user and link him to his session. If somebody else gains access to this cookie, he can use that same code to pretent he is the user, and that way he can get in without the password.

like image 157
Sjoerd Avatar answered Sep 27 '22 02:09

Sjoerd


Session could be modified in different occasions.. See this -> Session Poisoning

like image 42
Атанас Атанасов Avatar answered Sep 23 '22 02:09

Атанас Атанасов