Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question sessions passing to while

    Hello,

    I'm trying to pass a session variable to a while that is already running (it's holding a connection open), so when a user clicks a button, the session var is set..

    How it looks like:

    while
    if ($_SESSION['var'])
    // do something

    User clicks the button:
    set $_SESSION['var'];

    The problem is, I found out that session variables that are defined AFTER the while has been activated can no longer be passed through... So basically I need to pass variables to a while. I don't mind if it involves some other methods...

    Help would be GREATLY appreciated!

    Thanks.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    I'm thinking AJAX, but don't have an example for you.

    Sessions, like cookies are sent with a header (requiring a page refresh).

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    I'm thinking AJAX, but don't have an example for you.

    Sessions, like cookies are sent with a header (requiring a page refresh).
    Alright, thanks for telling me that, now I won't waste my time trying to make it work... Although I'm not that familiar with AJAX, can you give me more details about this?

    Thanks!

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    Describe more what is supposed to happen, and why the session variable.
    Also why there is a loop.

  • #5
    New Coder
    Join Date
    Aug 2007
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    Describe more what is supposed to happen, and why the session variable.
    Also why there is a loop.
    Alright, well I'm doing a fsockopen to a server, and I have a loop to retrieve all the data from it, so if the connection dies the loop ends too, but of course if all goes well the connection should stay open as well as the loop to retrieve all the data (fgets). I don't know if it can be done without a loop because the connection can idle for a while then spit something out. I want to have some control, I don't want it all going on auto-pilot, so that's why I put some IF's in the loop for user control, for example

    IF $_SESSION['terminate']
    // terminate connection

    etc... I don't know if this is kinda stupid or inefficient, but this is pretty much the only thing I can think of.


  •  

    Posting Permissions

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