开发者

Why is PHP $_SESSION changing token variable?

开发者 https://www.devze.com 2023-03-25 20:44 出处:网络
I\'ve got a really weird problem. This is my file: <?php session_start(); echo $_SESSION[\'token\']; // should print previous token

I've got a really weird problem.

This is my file:

<?php

session_start();

echo $_SESSION['token']; // should print previous token

echo "<br/>";    

$_SESSION['token'] = md5(uniqid()); // set new token

echo $_SESSION['token']; // new token whic开发者_开发百科h should carry through on page load, but doesn't

?>

Really simple!

The first echo statement should print the token set on the previous page load. But for some weird reason which I can't figure out, is that it prints an entirely different token!

Thanks a lot for any pointers.


Every time you request a webpage your browser makes a second request for /favicon.ico. If you have a rewrite rule mapping those requests to this script as well, that'd be changing your tokens.

0

精彩评论

暂无评论...
验证码 换一张
取 消