session problem

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
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

session problem

Post by shivam0101 »

I have the following link in main page where session is set

main page

Code: Select all

session_start();
$memberId=$_SESSION['member_id'];

echo "<a href='next_to_do.php')>session test</a>";// works
	
echo "<a href='javascript:void(0)' onClick=window.open('next_to_do.php')>session test</a>";// does not work
In the next_to_do page, i am not able to get memberId when i try to use popup
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: session problem

Post by Christopher »

To set a session variable it is:

Code: Select all

session_start();
$_SESSION['member_id'] = $memberId;
(#10850)
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

Code: Select all

session_start(); 
$_SESSION['member_id'] = $memberId;
The above code i have written in login page.

The problem is when i use window.open, i am not able to retain the session values i.e member_id.
http://au2.php.net/function.session-start an example from, jorrizza at gmail dot com

how to solve without using querystring?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If the session cookie has been set, you won't need the query string. However, if it has not, you will.
Post Reply