473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Sessions variable HELP please

Hi

Can Someone tell me why This doesnąt work:
Page 1

$_SESSION['composer'] = 'A non';

Page 2

Echo $_SESSION['composer'];

( I get undefined variable)

I am developing on version 4.2.3

I think I am missing something pretty fundamental here. Its driving me nuts.

Many thanks
Richard

Jul 16 '05 #1
3 14013
Richard Hulbert wrote:
Hi

Can Someone tell me why This doesnąt work:
Page 1

$_SESSION['composer'] = 'A non';

Page 2

Echo $_SESSION['composer'];

( I get undefined variable)

I am developing on version 4.2.3

I think I am missing something pretty fundamental here. Its driving me nuts.

Many thanks
Richard


do you have session_start() on the top of page 2 ?

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 16 '05 #2
in article 6K**************@news7.onvoy.net, Justin Koivisto at
sp**@koivi.com wrote on 10/7/03 8:01 pm:
Richard Hulbert wrote:
Hi

Can Someone tell me why This doesnąt work:
Page 1

$_SESSION['composer'] = 'A non';

Page 2

Echo $_SESSION['composer'];

( I get undefined variable)

I am developing on version 4.2.3

I think I am missing something pretty fundamental here. Its driving me nuts.

Many thanks
Richard


do you have session_start() on the top of page 2 ?


No That Was it many thanks!
But I would like to understand what's going on why put this on page two and
not page 1
I thought Session_start() initialised the session so any Session Variables
are Reset - Obviously I'm Wrong but can you explain?

Many many thanks for your time

Richard

Jul 16 '05 #3
Richard Hulbert wrote:
in article 6K**************@news7.onvoy.net, Justin Koivisto at
sp**@koivi.com wrote on 10/7/03 8:01 pm:
Richard Hulbert wrote:
Can Someone tell me why This doesnąt work:
Page 1

$_SESSION['composer'] = 'A non';

Page 2

Echo $_SESSION['composer'];

( I get undefined variable)


do you have session_start() on the top of page 2 ?


No That Was it many thanks!

But I would like to understand what's going on why put this on page two and
not page 1


session_start is to signify to support sessions. If there is no current
session data, it simply initializes the _SESSION array. If there is a
session in progress, it checks that it is valid, etc, then loads the
previous values into the _SESSION array.

You didn't need it on the first page beacuse assiging a value to an
element in _SESSION implicitly calls session_start first, then assigning
the value (at least when you haven't explicitly started the session).

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page...
9
by: Bartosz Wegrzyn | last post by:
I need help with sessions. I createt set of web site for nav with authorization. first I go into main.php which looks like this: <?php //common functions include_once '../login/common.php';...
2
by: Ik Ben Het | last post by:
Hello, I posted a simular question in the "IIS Security" group but it think it is more usefull to post it here. I want to do something very simpel. Make a part of my website available only...
1
by: jty202 | last post by:
1. Can I have an array of objects as sessions variable in other words sessions array-of-objects? If so how? 2. Besides Sessions variable what else can I use to store large amount of data...
12
by: D. Shane Fowlkes | last post by:
This is a repost (pasted below). Since my original post, I've double checked the system clock and set all IIS Session Timeout values to 10 minutes. Still ...the problem occurs. I've also...
8
by: lorenzdominic_ | last post by:
Hi I am new to sessions and php and have been playing around with them - and would like to know why this is happening? Firstly I have a login page and it goes to a verify page which creates a...
7
by: Steve Wright | last post by:
Forgive my ignorance, but I am just starting to learn about sessions in PHP and how to pass data from one page to the next. What I'm about to explain could just be my misunderstanding of how...
3
Atli
by: Atli | last post by:
Introduction: Sessions are one of the simplest and more powerful tools in a web developers arsenal. This tool is invaluable in dynamic web page development and it is one of those things every...
8
by: Chuck Anderson | last post by:
I've instituted a sessions based scheme on my web site to combat hot linking to my images. When someone requests a page at my site, I set a session variable. I then use htaccess to redirect *all*...
6
by: K. | last post by:
Hello!!!! I have a problems with sessions in mojavi technology. I have created a login panel to log into the system: Unfortunately sessions variable disappears while trying to click on any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.