multiple sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sneha Reddy
Forum Newbie
Posts: 5
Joined: Fri Dec 09, 2005 11:57 pm

multiple sessions

Post 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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

just set the array to a session. the popup window just use javascript window.open()
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post 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".
Sneha Reddy
Forum Newbie
Posts: 5
Joined: Fri Dec 09, 2005 11:57 pm

Array keeps changing

Post by Sneha Reddy »

Hi the array values keep changing

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

Thank You


Sneha
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
Sneha Reddy
Forum Newbie
Posts: 5
Joined: Fri Dec 09, 2005 11:57 pm

yes but....

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
Sneha Reddy
Forum Newbie
Posts: 5
Joined: Fri Dec 09, 2005 11:57 pm

Post 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
Sneha Reddy
Forum Newbie
Posts: 5
Joined: Fri Dec 09, 2005 11:57 pm

Post 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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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).
Post Reply