开发者

Restrict access to page with PHP

This seems really simple, and I see a lot of documentation about it, but I can't get it to work. Basically, I have a page "download-software.php" that we want only to be accessed from "download-registration.php" On the second page "download-r开发者_高级运维egistration.php" I have this:

<?php
  session_start();
  $_SESSION['authenticated'] = 'yes';
?>

and on the first page "download-software.php" I have this:

<?php
 session_start();
  if($_SESSION['authenticated'] != 'yes') {
    header("Location: http://kinetick.com/V3/download-free.php");
   };
 ?>

I need to kick the browser to the "download-free.php" page if they dont come from the first page. Can anyone help me out pls?

**Edit** added session_start(); still doesn't work.


You need to add another session_start() to the beginning of download-software.php to resume the session you started from download-registration.php.


You forgot session_start() on download-software.php You must always call session_start() before any html data to be able to use $_SESSION in your script

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜