Page 1 of 1

multiple sessions

Posted: Sat Dec 10, 2005 12:08 am
by Sneha Reddy
Hi all,

This is very urgent. I need help!!!

I need to instantiaite a pop-up window from PHP script and pass an array values from PHP script to the window.
the user selects some of them from a list of those array values(say they are in a multiple select list box) and the values are again sent back to the parent script. Here the problem is: I need to instantiate the pop-up window multiple times from the PHP script (that means multiple sessions).

Is it possible? let me know please.

Thank You

Sneha

Posted: Sat Dec 10, 2005 6:55 am
by shiznatix
just set the array to a session. the popup window just use javascript window.open()

Posted: Sat Dec 10, 2005 7:54 am
by patrikG
There is no need for "multiple" sessions. $_SESSION is a suberglobal and can hold values of arrays, objects etc. Just assign a key to each pop-up window and use that key as a key for an array in $_SESSION, e.g. $_SESSION["pop_up"][1]="whatever".

Array keeps changing

Posted: Sat Dec 10, 2005 12:11 pm
by Sneha Reddy
Hi the array values keep changing

like my $_SESSION['myArray'].....here "myarray" keeps changing in the recursive function.

Thank You


Sneha

Posted: Sat Dec 10, 2005 12:27 pm
by shiznatix
:?: are you having a problem where its changing when you dont want it to change or what? $_SESSION values will not just randomly change, somwhere in your script that are being changed.

yes but....

Posted: Sat Dec 10, 2005 3:08 pm
by Sneha Reddy
There is a recursive function in the script...in which there is an array 'myarray'.

every time the function is called we get new values into it. Based on them we have to generate a pop-up window which shows all the values of that array in it and the user has to select some. these some values should be sent back to the parent script.( Do i have to use java script), beacause to pop-up windows from PHP you were saying i need java script. I am new to PHP, so this is a bit confusing to me.

My question is every time i get new values into an array how do I store them in a session....Patrick said something about assigning a key. Can you just help me with it.


Hope this is clear.

Thanks

Sneha

Posted: Sat Dec 10, 2005 3:13 pm
by John Cartwright
lets say you had an array "myarray"

Code: Select all

$myarray = array(
   'key1' => 'value1',
   'key2' => 'value2',
);
and I wanted to store this array as a session

Code: Select all

$_SESSION['myarray'] = $myarray;
and to access the array

Code: Select all

echo $_SESSION['myarray']['key1']; //outputs value1
hope that clears things up

Posted: Sat Dec 10, 2005 3:32 pm
by Sneha Reddy
Thanks for the reply Jcart,

This is where my problem is . I am using indexed arrays here. How can I initiate java script from PHP. And how do I access them in my pop-up window?
Like every time we want to initiate a pop-up window, can we access the array elements as
_SESSION ['myarray']['key1'] ?




In my function I have an array 'myarray' with the elements ['she','he','we'] i need to to initiate a pop-up window and the user has to select she and he from the above . and the he and she has to be passes back to the parent script..


Again when the function is called the array element contents change ['pen','paper','book'....] and the same procedure repeats. This goes on and on till some condition is satisfied in the function

hope I am not asking silly questions.


Thanks a lot

Posted: Sat Dec 10, 2005 7:06 pm
by Sneha Reddy
Hi ,


I could figure out somethings. But just let me know onething........

When I open a pop-up window from PHP using window.open(abc.html.....). How do I acces my session variable at abc.html.

Thank You

Sneha

Posted: Sat Dec 10, 2005 7:11 pm
by shiznatix
your cant access a $_SESSION variable on a .html page. to use sessions on a page it has to be a .php page (unless you do mod rewrites which we wont go into right now).