PHP session not working in Safari, Webkit Nightly

My site has an index page, and this page checks if a php session is established using:

session_start();

$name = $_SESSION["name"];

if (!$name) {
  header('Location: name.php');
}

name.php has a simple form for setting the name (without php) with the setName.php action. setName.php:

session_start();

$_SESSION["name"] = $_POST["name"];

header('Location: index.php');

In every browser except safari (and Webkit Nightly), the user sets his name and returns to the index. However, in S (& WN) Submission of the name form returns to the same page.

Cookies are enabled for all sites, and session ID: enter image description here

Edit: in case that matters, my server is a macbook with MAMP since php 5.3.

If you want to try this yourself, the url is 121.73.150.105/questions, but it is often disabled.

+5
source share
7 answers

, PHP- "":

HTTP/1.1 URI "Location": , , URI.

PHP

+3

: header('Location: index.php');

: header('Location: index.php'); exit();

PHP , . , $_SESSION , . .

0

@JJ56, , , , .

index.php

<?php 

session_start();

$name = $_SESSION["name"];

if (!$name) {
  exit(header('Location: name.php'));
}

echo "Name is $name.";

?>

name.php

<!doctype html>
<html>
  <head>
    <title>Questions Test</title>
  </head>
  <body>
    <form method="post" action="setName.php">
      <input type="text" name="name">
      <input type="submit" name="submit">
    </form>
  </body>
<html>

setName.php

<?php 

session_start();

$_SESSION["name"] = $_POST["name"];

header('Location: index.php');

?>
0

cookie PHPSESSID.
, iframe php: url_rewriter.tags.

http (Location:) http .

header('Location: name.php?'.htmlspecialchars(SID));

SID php session_name().'='.session_id()
PHP: .

webkit, , cookie .

session_id () cookie, ini.session.use-cookies = 0 ( ) .

0

:

if (!$name) {
  session_write_close();
  header('Location: name.php');
}
0

"header ('Location: name.php');" ex: ': http://...name.php' http://...ect -.

0

, ( Webkit Nightly), . S (& WN) .

, PHP, HTML . ?

0

All Articles