PHP Session Variable 
July 2nd, 2009, 01:51 PM
| | Member | | Join Date: May 2009 Location: Goregaon, मुंबई IN :)
Posts: 85
| |
Hello,
I'm new to php,
I'm storing temp variable in SESSION - $_SESSION['temp']='value';
when i go from one php page to other php page, the session variable is accessible
but when i go to the other page in a subdirectory.. the SESSION variable is not accesible..
am i missing some php configuration?
pls help
regards,
Nitin Sawant
| 
July 2nd, 2009, 02:09 PM
|  | Expert | | Join Date: Mar 2007 Location: England
Posts: 1,063
Provided Answers: 2 | | | re: PHP Session Variable Quote: |
but when i go to the other page in a subdirectory
| PHP does not have a GOTO command!
| 
July 2nd, 2009, 03:08 PM
| | Member | | Join Date: May 2009 Location: Goregaon, मुंबई IN :)
Posts: 85
| | | re: PHP Session Variable
Hello code green,
I'm navigating from one page to another page in subdirectory
suppose: current page 'index1.php'
then in that page i write -
<a href='std/index2.php'>go to subdirectory</a>
-
then the session variable is lost when i navigate to 'index2.php' in std subdirectory..
| 
July 2nd, 2009, 03:25 PM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,485
Provided Answers: 9 | | | re: PHP Session Variable
is in that page the session restarted?
| 
July 2nd, 2009, 03:49 PM
| | Member | | Join Date: May 2009 Location: Goregaon, मुंबई IN :)
Posts: 85
| | | re: PHP Session Variable
nope, the session is not restarted..
in index1.php page i wrote.. -
if (!isset($_SESSION)) {
-
session_start();
-
}
-
$_SESSION['temp']='value';
-
and in the index2.php page in std directory i'm trying to retrieve the variable | 
July 2nd, 2009, 04:24 PM
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,858
Provided Answers: 9 | | | re: PHP Session Variable Quote:
Originally Posted by code green PHP does not have a GOTO command! | It does now :P
| 
July 2nd, 2009, 04:40 PM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,485
Provided Answers: 9 | | | re: PHP Session Variable Quote:
Originally Posted by NitinSawant nope, the session is not restarted.. | as I thought… you need to open a session first: Quote: |
Originally Posted by php.net Note: […] Also note that you must start your session using session_start() before use of $_SESSION becomes available. […] | | 
July 3rd, 2009, 04:21 AM
| | Member | | Join Date: May 2009 Location: Goregaon, मुंबई IN :)
Posts: 85
| | | re: PHP Session Variable
But i'm starting the session on index page only | 
July 3rd, 2009, 05:35 AM
| | Member | | Join Date: May 2009 Location: Goregaon, मुंबई IN :)
Posts: 85
| | | re: PHP Session Variable
well, what i was missing is adding 'session_start();' on every page...
nevermind, i got it..
prob. solved
regards,
Nitin Sawant
| 
July 3rd, 2009, 10:56 AM
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,858
Provided Answers: 9 | | | re: PHP Session Variable Quote:
Originally Posted by NitinSawant well, what i was missing is adding 'session_start();' on every page...
nevermind, i got it..
prob. solved
regards,
Nitin Sawant | That's exactly what Dormilich told you to do. :)
| 
July 6th, 2009, 04:39 PM
|  | Expert | | Join Date: Dec 2007 Location: Moon, Dark Side
Posts: 1,075
| | | re: PHP Session Variable Quote:
Originally Posted by code green PHP does not have a GOTO command! | Thanks for the laugh starting my Monday, it's been a sh*tty week.
Dan
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|