SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 29 of 29
  1. #26
    SitePoint Addict skunkbad's Avatar
    Join Date
    Apr 2008
    Location
    Temecula, CA
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by agentforte View Post
    I know that my problem has nothing to do with the session handler because sessions are handled properly by my application without ajax. I also used a custom session handler that was in the sitepoint PHP Anthology book.

    skunkbad, your solution is the only one I have not tried. It looks like that has a good chance of solving my problem. Unfortunately I get an error "http is not defined" when using the line:

    PHP Code:
    <?php echo "http.setRequestHeader('Cookie','yourcookiename=" session_id() . "');''; ?>
    Any tips? Note that I changed "yourcookiename" using the value echoed by session_name().


    Here is the ajax call that I use (after creating the URL, which works as expected when I copy it into the address bar. For some reason it does not work when called by javascript. I have a feeling this has to do with the client side storing a cookie which is not updated by ajax):

    HTML Code:
    	// Create new JS element
    	var jsel = document.createElement('SCRIPT');
    	jsel.type = 'text/javascript';
    	jsel.src = url;
    
    	// Append JS element (therefore executing the 'AJAX' call)
    	document.body.appendChild (jsel);
    I find this is much more elegant than using an ActiveXObject as shown by rajug.
    I am creating a request object called http, and that is why http is http. If your request object is named something other than http, then replace http with that name... I am not sure how you would do it if you aren't creating a request object. Honestly, I fumble through AJAX, so I am not an expert by any means. I am only offering suggestions based on my experience.

  2. #27
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,196
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by skunkbab
    Yes, it is Apache
    Ok, just did a few tests myself with FF3 and Safari (Mac) but did not run into the issue you mentioned from here. It is possible this is caused by some settings / configuration on your host's server.

    Though always nice to know about possible issues/problems like this, as you never know what you will run into in the future. Ive seen too many times that a badly configured/setup server has caused problems that it takes hours to figure out why they happen.

    Quote Originally Posted by agentforte
    Here is the ajax call that I use (after creating the URL, which works as expected when I copy it into the address bar. For some reason it does not work when called by javascript. I have a feeling this has to do with the client side storing a cookie which is not updated by ajax):

    I find this is much more elegant than using an ActiveXObject as shown by rajug.
    Is it more "elegant"?

    I strongly recommend that you actually learn what the term/abbreviation's you use means before using them. While your at it, study up on the http specifications and they way they work as well.

    First, what you use is not a "AJAX" call. While I dont like the term in general since the functionality was around years before people started to call it "AJAX" I do understand why people use it.

    There is nothing Asyncron with the call you do, actually what you do is to include an "external javascript" into the browser. Depending how you do that there is several issues that can happen, including severe race conditions.

    If you want to run something asyncron or even syncron for that matter, do it the correct way. It does not need to be complicated, the code you use decide that.

    For example, here is a except from the manual on our internal JS framework on how to initiate and load a javascript request.

    resource Kaizen.AJAX.Request ( string url, resource callbackFunc [, bool async [, string user, string pass]] )

    void load ( string data [, string method [, array headers]] )

    These two commands is all that is needed to initiate and run a javascript request. Everything else is handled automatically.

    Back to your issue.

    I mentioned it before, you DO NOT need to include the session id or the cookie with the request, as the cookie is sent with every request by default.

    If your doing a cross domain request, there is many reasons for the fact that you have issues, but I do not believe this is what you try to do.

    It is possible that you have a race condition happening here, you need to go over the code and find out what exactly happen when your request is being initiated. I.e. when is the so called "AJAX" request initiated, what else is happening during the same time etc.

    If your still not able to sort it out, paste the entire code for both pages here and we might be able to spot the issue for you.

  3. #28
    SitePoint Addict skunkbad's Avatar
    Join Date
    Apr 2008
    Location
    Temecula, CA
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @TheRedDevil:

    I've got an image of my phpinfo(), and you can see it here:
    http://www.ramseys-auto-detailing.com/phpinfo.gif

    I think every server is different, and there is always a surprise awaiting me in regards to something not working on one server, but working on another. It does drive me nuts sometimes to figure out what is wrong with code that should work but doesn't. It's just part of the fun I guess.

  4. #29
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by agentforte View Post
    I know that my problem has nothing to do with the session handler because sessions are handled properly by my application without ajax. I also used a custom session handler that was in the sitepoint PHP Anthology book.
    While your problem might be something else, this is extremely poor logic. You making assumptions that things are working how you expect, and that you fully understand how things work, is the reason you have a problem. You need to debug. Check your assumptions. Sessions are not black magic, but few people understand how they work in detail.


Tags for this Thread

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
  •