drxdn40242 2010-11-17 12:00
浏览 25
已采纳

$ _SESSION在URL中没有文件名时不能正常工作?

I'm currently working on a site where I'm trying to make use of the session variables.

I have a controller script (index.php) that begins with session_start(); and has two different HTML files included within if statements. Everything works all groovy when I go to /quote/index.php, the session variables that I've set are echoed on the page as expected, however if I remove 'index.php*' from the URL so it points to just /quote the page loads however none of the session variables show up.

I'm not using session_destroy anywhere in my scripts and the session variables aren't echoing '0' so I'm fairly sure they aren't being unset, it seems as though they are just ignored without the filename in the URL!

Any insight as to why this is occuring would be awesome, Thanks

/quote/index.php (with extraneous bits removed):

<?php
session_start();

if (isset($_GET['form']))
    {
include 'form.html.php';
exit();
    }
if (isset($_GET['fetchquote'])) 
    {
    $width = mysqli_real_escape_string($link, $_POST['width']);
    $height = mysqli_real_escape_string($link, $_POST['height']);
    $_SESSION['height'] = $height;
    $_SESSION['width'] = $width;
    }
include 'quote.html.php';
?>

The session variables are echoed in quote.html.php

  • 写回答

3条回答 默认 最新

  • douqie1816 2010-11-17 12:15
    关注

    what are the two file names? seems that one of the file that you are including is named index.html and resides in the mysite.com/quote/ itself. And if I am not wrong, if in a directory there are index.html and index.php then the index.html is loaded by default unless the file is explicitly specified in the url. So it seems in your case when you are not specifying the index.php explicitly,the index.html is being loaded.Of course this is the case only if there is an index.html there in the directory.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题