Page 1 of 1

problem with sessions

Posted: Mon Dec 25, 2006 2:55 am
by paul_20k
Hi

I have 15 links on a page. There are different types of mysql queries on all those linked pages. I am getting the variable for these queries from another page by passing that variable through URL.

When I open the first page , it works fine and I am using session to pass that variable value to the rest of the linked pages. I can reach variable on all those pages. But as soon as I leave the first page, I can't open that page again. I am getting that variable on the first page by $_GET and passing values to other pages by sessions.

I can open all other pages as many times as I want but I can't open the first page again. Am I making some mistake with the GET and SESSIONS? I am using this session on first page. I am using this name variable on all other pages.

Code: Select all

session_start();
$_SESSION['name']=$_GET['name'];
I am getting error message after I try to open the first page.

Code: Select all

Notice: Undefined index: name in c:\program files\.................php on line 5
I tried all options but nothing worked so far.

Thanks

Posted: Mon Dec 25, 2006 3:27 am
by dude81
use

Code: Select all

isset($_GET['name'])
This should solve the problem


Dude

Posted: Mon Dec 25, 2006 4:35 am
by dibyendrah
Alternative approach would be

Code: Select all

if(isset($_GET['name'])){
    $name = $_GET['name'];
}
if(!empty($name)){
    $_SESSION['name'] = $name;
}

Posted: Mon Dec 25, 2006 8:25 am
by paul_20k
hi

thanks for replies. its working now.