Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: Stored Sessions Data Not Found

  1. #21
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by marain View Post
    One of the items on the checklist is "8.Make sure your file extension is .php (it happens!)". My site sets defines the session index in a file with a .php extension, but it redirects to a .txt extension!
    The takeaway from that is to make sure that the file is actually being executed as PHP. As long as you're including it it and/or executing it as a PHP file, everything should work out fine. However, if you do want to test and make sure this isn't the issue, here's another case you can run:

    index.php
    PHP Code:
    <?php
    session_start
    ();

    if( isset( 
    $_GET'session-set' ] ))
    {
        include( 
    'detect.txt' );
        
    session_unset();
        exit;
    }

    $_SESSION'foo' ] = true;
    header'Location: index.php?session-set' );
    detect.txt
    PHP Code:
    <?php

    echo isset( $_SESSION'foo' ] ) ? "Session worked." "Session failed.";
    If this returns session failed, the text file is not necessarily the issue and we'd have to do further debugging to verify.

    Quote Originally Posted by marain View Post
    I attempted to try it, got 404-type error.
    Sorry, make sure that the PHP file is called "redirect.php", otherwise the script redirects to another page. (Or just modify the script, whatever you feel is easier).

  2. #22
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by marain View Post
    I use PHP version 5.2.9
    I highly recommend upgrading. 5.2 reached its end-of-life in 2011 and is no longer supported (receives no security patches, either).

    Quote Originally Posted by marain View Post
    One of the items on the checklist is "8.Make sure your file extension is .php (it happens!)". My site sets defines the session index in a file with a .php extension, but it redirects to a .txt extension! My domain where sessions works uneventfully involves redirects to files with .php extensions. That strikes me as something to try. I think that setting that up, for me, won't be easy, on account of the present file navigation scheme.
    Notice: Undefined index: code in /var/www/html/pageContent/quotations.txt on line 2956
    Because you are getting PHP errors from quotations.txt, we know that the file is indeed being executed by PHP. If your session start automatically, they will be started in any file PHP runs, regardless of the file extension.

    Did you check your session contents on the quotations.php page?
    Quote Originally Posted by traq
    Have you tried using print_r( $_SESSION ); at the top of your quotations page, to see what values are being carried over?

  3. #23
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    138
    Thanks
    51
    Thanked 0 Times in 0 Posts

    Default

    Traq,

    Thanks for the heads up re PHP 5.2. If my host supports a more recent version (I suspect it does), I'll update.

    print_r( $_SESSION ); yields Array ()

    Niles,

    I made the calling script (not the index):
    PHP Code:
    <?php
    session_start
    ();

    if( isset( 
    $_GET'test' ] ))
    {
        echo isset( 
    $_SESSION'test' ] ) ? "Session worked" "Session failed";
        
    session_unset();
        exit();
    }

    $_SESSION'test' ] = true;

    header'Location: page.php?here=test' );
    and again got the 404. I suspect I'm doing it incorrectly. You may have to spoon feed that to me if I'm preparing it incorrectly.

    Both:

    You've put huge amounts of time into this, this weekend, which I greatly appreciate. I'm inclined to look at it more, but this is, for me, a hobby and, unfortunately, real life beckons. I will return to this, but it may be a few days. I am very apologetic that your valued suggestions have not enabled me to provide you the satisfaction of saying "Problem solved." I also suspect strongly that the problem may arise from the particular way my site was set up. That makes the problem very difficult to reproduce.

    I'll check for response to this thread, but will be likely unable to implement any further suggestions quickly.

    A.

  4. #24
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Make sure that the location in the header redirect ("page.php") matches the files name it's in. Or just change that line entirely to:

    PHP Code:
    header'Location: http://' $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?test' ); 
    Last edited by Nile; 01-06-2014 at 12:54 AM. Reason: Updated to use absolute path as suggested by traq below

  5. #25
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by marain View Post
    print_r( $_SESSION ); yields Array ()
    Meaning, the session values are not being carried between pages. What you have is a new, empty session.

    Quote Originally Posted by marain View Post
    PHP Code:
    header'Location: page.php?here=test' ); 
    and again got the 404.
    Do you have a page named "page.php"?

    Also, note that Location headers require a fully qualified URL, not only a path. You need to include the scheme and domain name as well:
    Code:
    Location: http://example.com/page.php?here=test
    Many times, you get the same results when you omit them, but it won't work in all browsers under all circumstances.

    (correct me if I'm wrong,) Looking back through this thread, I don't see that you have checked to make sure your browser is accepting the session cookie or not (for example, in Chrome, click on the menu icon -> Settings -> show advanced settings -> [Content Settings] -> [All cookies and site data])?

    Speaking of, is PHP configured to use cookies? I don't know why it wouldn't be (and it should not be), but if it is, then the session id might not be being transferred across pages.

    Further, you can test if the sessions on each page are the same session or not by using print session_id(); on both pages (if they are different, then it's not the same session).
    Last edited by jscheuer1; 01-06-2014 at 01:12 AM. Reason: typo

  6. #26
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    138
    Thanks
    51
    Thanked 0 Times in 0 Posts

    Default

    Folks,

    I'm going to try a new approach. Answering Traq, I DO have a page called page.php. I was going to upload that page for everyone's review. My new approach, however, will be to bypass that page completely for the one page on this domain that tries to use sessions.

    Traq, I followed your suggestion. I'm now using PHP 5.3.8.

    A.

  7. #27
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

Similar Threads

  1. Refill "File" form field with stored image data
    By pelaej in forum MySQL and other databases
    Replies: 3
    Last Post: 10-22-2010, 07:28 PM
  2. sql stored procedure
    By aldo007 in forum MySQL and other databases
    Replies: 0
    Last Post: 08-30-2010, 01:41 PM
  3. Types of data to be stored in an array
    By heavensgate15 in forum PHP
    Replies: 1
    Last Post: 05-14-2010, 05:10 PM
  4. Increment a Value Stored in the DB
    By Moshambi in forum MySQL and other databases
    Replies: 3
    Last Post: 04-08-2009, 11:21 AM
  5. login script "user data not found"
    By jimo in forum PHP
    Replies: 10
    Last Post: 01-13-2007, 06:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •