Sessions not working?

Discussion in 'PHP' started by Imozeb, Mar 27, 2010.

  1. #1
    I have a file that sets a session and then an AJAX javascript file calls another file that should read the first files session. It looks like this.

    mainfile.php //creates session --> AJAX javascript in main file // calls file2.php --> file2.php gets mainfile.php's session.

    It should work but it doesn't, what do you guys think I'm doing wrong?

    Basicly I want to create a variable containing mainfile's file name and get the variable in the second PHP file for processing. Please tell me how to do this.

    Thanks.

    ~imozeb :)
     
    Imozeb, Mar 27, 2010 IP
  2. Ryabinchik

    Ryabinchik Member

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #2
    I think you should contact support. I rent VDS and I couldn't solve this problem by myself.
     
    Ryabinchik, Mar 27, 2010 IP
  3. mnvlxxx

    mnvlxxx Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If you don't have it already, try placing this on the begining of file2.php:
    session_start();
    Code (markup):
     
    mnvlxxx, Mar 27, 2010 IP
  4. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I did already place session_start(); at the beginning of my second and first php pages. Can anyone tell me a work around for this problem.

    I want a way to pass a variable from one PHP script to another without using sessions cause it's broken and it has to be secure so I can't use cookies. Is there any other way?
     
    Imozeb, Mar 27, 2010 IP
  5. mnvlxxx

    mnvlxxx Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try using cURL with POST method. There is an example here.
     
    mnvlxxx, Mar 27, 2010 IP
  6. guardian999

    guardian999 Well-Known Member

    Messages:
    376
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #6
    check is your session already set
    
    if(isset($_SESSION['name'])){
         return true;
    }
    
    PHP:
     
    guardian999, Mar 27, 2010 IP
  7. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It is not set in the second file. I guess I'll have to take a look a cURL.
     
    Imozeb, Mar 28, 2010 IP
  8. mnvlxxx

    mnvlxxx Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    PM me if you need some help.
     
    mnvlxxx, Mar 28, 2010 IP
  9. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I screwed around with the sessions somemore and I found a few glitches. The sessions are working again but I figured out that I didn't need them. :) Crap.
     
    Imozeb, Mar 28, 2010 IP