$_SESSION wont work without filename in 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

-------------Problems Reply------------

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.

Make sure you are also using session_start() at the top of the PHP pages where you want to echo the session variable. And make sure index.php is the only index in your root.

You are checking if an option is set via the GET method. Where is your form using the GET method?

Post your entire script and you'll get much better answers.

This has probably something to do with the validity scope of the session ID cookie. Because if the cookie path is set to /quote/, the cookie will only be available in /quote/ and beyond.

Category:php Views:0 Time:2010-11-17

Related post

  • REGEX: Capture Filename from URL without file extention 2010-09-08

    So I am trying to create a Javascript Regex that captures the filename without the file extension. I have read the other posts here and 'goto this page: http://gunblad3.blogspot.com/2008/05/uri-url-parsing.html' seems to be the default answer. This d

  • How to extract the filename of URL in JavaScript? 2011-07-01

    I'm trying to extract the current file name in Javascript without any parameters. $(location).attr('href').match(/([a-zA-Z\-\_0-9]+\.\w+)$/); var current_path = RegExp.$1; if ((current_path == 'index.html') || ...) { // something here } But it doesn'

  • js function to get filename from url 2009-02-04

    I have a url like http://www.example.com/blah/th.html I need a javascript function to give me the 'th' value from that. All my urls have the same format (2 letter filenames, with .html extension). I want it to be a safe function, so if someone passes

  • regexp get filename from url 2009-09-12

    url: http://blabla.bl/blabla/ss/sd/filename How to get a filename? --------------Solutions------------- Use earcar's suggestion (basename) to get the filename. BUT, if we're starting with a URL and the filename includes a query string, use Mauris's s

  • XSL Get filename from URL 2009-09-30

    I need to get just the filename from this url: http://feedproxy.google.com/~r/TEDTalks_video/~5/XT8k_DqlzGc/KarenArmstrong_2009G.mp4 So I need to get: KarenArmstrong_2009G I need the filename so I can add .jpg to it and another base url.

  • using header() to rewrite filename in URL for dynamic pdf 2010-01-06

    I have a php script that generates a pdf report. When we go to save the pdf document, the filename that Acrobat suggests is report_pdf, since the php script is named report_pdf.php. I would like to dynamically name the pdf file, so I don't have to ty

  • regular expression to get the filename from urls 2010-06-13

    if i have a textbox with severals urls rapidshare.com/files/379028801/foo.bar.HDTV.XviD-LOL.avi rapidshare.com/files/379182651/foo.bar.720p.HDTV.X264-DIMENSION.mkv rapidshare.com/files/379180004/foo.bar.720p.HDTV.X264-DIMENSION.part1.rar rapidshare.c

  • Get filename from URL using Regular Expressions or Javascript 2010-12-28

    I need to get the filename from the URL address. Here is the criteria: It need to return empty string "" in following scenarios: http://somedomain.com http://www.somedomain.com http://somedomain.com/ http://www.somedomain.com/ And return filename.php

  • FileName from url excluding querystring 2011-05-17

    I have a url : http://www.xyz.com/a/test.jsp?a=b&c=d How do I get test.jsp of it ? --------------Solutions------------- This should do it: var path = document.location.pathname, file = path.substr(path.lastIndexOf('/')); Reference: document.locat

  • Get only filename from url in php without any variable values which exist in the url 2011-10-21

    I want to get filename without any $_GET variable values from a url in php? My url is http://learner.com/learningphp.php?lid=1348 I only want to retrieve the learningphp.php from the url? How to do this? Please help. I used basename but it gives all

  • Get filenames by URL Directory in WinService or WinForms application 2011-12-12

    I have win service which must download all zip files by URL(for example http://download.geonames.org/export/dump/) but when i use Directory.GetFiles method or DirectoryInfo di = new DirectoryInfo(ConfigurationManager.AppSettings["GeoFullDataURLPath"]

  • Getting Filename from url in C# 2011-12-14

    Currently we have a solution that grabs the filename from the URL using this currentFile = Path.GetFileNameWithoutExtension(url); We found that if there are query strings attached that include characters such as quotes it returns with an error of Ill

  • How do I remove get variables and filename from URL using javascript/jquery? 2012-02-04

    I was looking into this issue but I couldn't find any solid answers for this specific purpose. Let's say I have a URL of... http://mysite.com/stuff/index.php?search=my+search How can I grab this URL and remove index.php?search=my+search from it so it

  • FileName from URL (overwriting) 2012-03-19

    I would like to know how to get the filename from the URL so that it could download into SDCARD without overwriting the new files. int lenghtOfFile = conexion.getContentLength(); Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile); String fileNam

  • Isapi Rewrite : Remove filename from URL 2010-04-19

    Im am trying to use the isapi rewrite tool on my web domain to write some basic rules, but am getting a bit confused. My base url is http://forevr-dev.co.uk/musicexplained/index.cfm and every page on the site follows from this base url. For example h

  • Regular Expression to extract path + filename from URL 2011-06-02

    I am trying to extract 'vets/gth/summary.htm' from 'http://www.abc.gh.gov/vets/gth/summary.htm' by using the following regular expression: ^http:\/\/www.abc.gh.gov I get the following output: 'ets/gth/summary.htm' I do not get the 'v' in the vets. If

  • Need help removing part of filename from url with mod_rewrite 2011-12-01

    I'm trying to reformat my url to be a bit shorter. Right now the links end up as this: website.com/image?id=name.jpg What I want to have the link come out as is m.website.com/name, without the file exension or image.php file in the url. I figure mod_

  • PHP/HTML > Category instead of filename in url 2012-01-23

    first I'll show you what I'm currently working with and then I'll show you what I would like to happen instead. Homepage index.html contains a list of states, user clicks on the state and they are directed to cities.html in order to pick a city. So w

  • Hide website filenames in URL 2012-02-22

    I would like to hide the webpage name in the url and only display either the domain name or parts of it. For example: I have a website called "MyWebSite". The url is: localhost:8080/mywebsite/welcome.xhtml. I would like to display only the "localhost

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.177 (s). 11 q(s)