Forum Moderators: coopster

Message Too Old, No Replies

Session Variables

Session Variables

         

crankshaft

8:16 am on Mar 27, 2005 (gmt 0)

10+ Year Member



Hi Everyone;

My first post :)

I am trying to use session variables to pass the background colour of a page loaded into a frame using session variables:

I declare tyhe colour in the main page which loads first, this is the content in the main page and echos OK.

$_SESSION['content_color'] = "#E9E9E9";
echo $_SESSION['content_color'];

However if I echo the session variable in my loaded page in another frame I don't get anything at all!

Any ideas?

Thanx

Crankshaft

Francis

8:21 am on Mar 27, 2005 (gmt 0)

10+ Year Member



Why don't you try putting:

session_start();

on the receiving page?

I think this is because the receiving page needs to know the variable you are using for the color.

Please correct me if I'm wrong.

coopster

3:04 pm on Mar 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You aren't wrong.

Welcome to WebmasterWorld, crankshaft.

You need to start a session for every page in which you want to set or retrieve session variables and their associated values.

anshul

10:03 am on Mar 28, 2005 (gmt 0)

10+ Year Member



Transit the session id ( SID ) in the url to other pages. Use session_start() at top of Web page code, ( before sending anything to client ) e.g.,
<a href="transit.php?<?php echo strip_tags(SID);? ">Go</a>

crankshaft

5:13 am on Mar 29, 2005 (gmt 0)

10+ Year Member



Great;

Thanx so much for all your feedback, adding the start session to the receiving page did the trick :)

anshul

11:39 am on Apr 25, 2005 (gmt 0)

10+ Year Member



I wanna ask, if session variables are available when we register a cookie. Or, we've to register both cookies and sessions ( if client is not accepting cookies ).

coopster

3:00 am on Apr 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Cookies and sessions are two separate animals. Session management often uses cookies, though. Have a read through PHP's Session Handling Functions [php.net] for more information.