...

View Full Version : sessions passing to while



koolaid
02-21-2008, 08:27 PM
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.

mlseim
02-21-2008, 08:42 PM
I'm thinking AJAX, but don't have an example for you.

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

koolaid
02-22-2008, 10:13 AM
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!

mlseim
02-22-2008, 12:49 PM
Describe more what is supposed to happen, and why the session variable.
Also why there is a loop.

koolaid
02-22-2008, 01:17 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum