Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2006, 03:09 AM
Authorized User
 
Join Date: Jun 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default my session variables not retaining values

hi all
i have been trying to use session variables but getting no results
my site is multipage and from first page i am storing value in session variable and retrieving it back in other pages but no variable retains its value in other pages
what i did was

if globalregister off

$page=$_GET["page"];
if($page > 1)
{
session_start();
 $emp_nos = $_SESSION['MyEmpNos'];
/*for all other pages */
}
else
{
session_start();
  $_SESSION['MyEmpNos'] = $emp_nos;
/*in my first page*/
}

but i am not getting MyEmpNos value retained in further pages

i tried even with global register = ON
and used
session_register()
also

but no results then to o
can somebody please help.................i need it urgently ..




nidhi
__________________
nidhi
 
Old June 20th, 2006, 08:05 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

The first thing I can see is that you need to close the remark surrounding
/*for all other pages

add a */ at the end

In effect this is causing the whole block behind it to skip and the Session varibale is never set. Register Globals will not have any effect on Session Variables either.

HTH

Mike

Mike
EchoVue.com
 
Old June 21st, 2006, 12:13 AM
Authorized User
 
Join Date: Jun 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi Mr.
Thanks a lot for your suggestion but after comment properly also there is still some problem with session variable..
and ya it has relation with register global directive surely
please reply if you can guess the problem

nidhi
 
Old June 21st, 2006, 01:41 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

What version of PHP are you using?

Mike
EchoVue.com
 
Old June 22nd, 2006, 12:32 AM
Authorized User
 
Join Date: Jun 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello
its php -4
but i got the solution it was because i had a few blank spaces before session_start so session could not send cookies headers were already sent ..
thanks for your effort ..
Nidhi

nidhi
 
Old June 22nd, 2006, 12:35 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

No worries - I had that problem last week - you think I would have remembered

Mike
EchoVue.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
my session variables not retaining values nidhimittal Beginning PHP 4 July 7th, 2006 12:33 AM
retaining values of controls inside a datagrid @shish ASP.NET 1.0 and 1.1 Professional 0 March 22nd, 2006 05:49 AM
retaining the session of the databse vmaruv SQL Server 2000 0 April 6th, 2005 10:02 AM
Is it possible for me using session variables into see07 ASP.NET 1.x and 2.0 Application Design 4 March 9th, 2005 07:46 PM
session variables help face Classic ASP Databases 4 September 12th, 2003 03:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.