Session
Posted on
16th Feb 2014 07:03 pm by
admin
I am having a little trouble with a session. Not sure if it is my browser or what. I know I do not have any trouble logging into forums such at these, so not sure why this is not working.
first the code. Just basic code from php documentation plus some added checks.
Code: <?php
// page1.php
if (session_start()) {
echo "OK";
} else {
echo "FAIL";
}
// echo phpinfo();
// echo getcwd();
echo 'Welcome to page #1';
$_SESSION['favcolor'] = 'green';
$_SESSION['animal'] = 'cat';
$_SESSION['time'] = time();
print_r($_SESSION);
// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';
// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>
And
Code: <?php
// page2.php
session_start();
echo 'Welcome to page #2<br />';
echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
echo date('Y m d H:i:s', $_SESSION['time']);
print_r($_SESSION);
// You may want to use SID here, like we did in page1.php
echo '<br /><a href="page1.php">page 1</a>';
?>
There is no reason why this should not work. Can someone go to:
http://www.e-sullivan.com/DIITop25/page1.php
and tell me if it works for you? It shows me that the sessions are being started but the variables are not passing between page1.php and page2.php for me.
No comments posted yet
Your Answer:
Login to answer
331
8
Other forums
PHP4 to PHP5 Conversion
Hi Everyone,
I am working on a site that is built up on PHP4 and each page is being started f
Date help - fetch dates for Mondays between xxx and yyy?
Does anyone know the best way to do this? I have two dates, say:
2010-01-26 and 2010-05-30
LOOPing Problem
Hello All!
The following code loops through the data and displays the data accordingly. My p
upload form file types....
Hey all, I am learning PHP and I am writing a script from the W3C Schools tutorials for uploading fi
SOAP Issue
Hi,
I am facing some understanding problem with SOAP basic.kindly recommend some SOAP expert.
Warning: mysql_num_rows() supplied argument is not a valid MySQL result resource
This may be simple I just may need another pair of eyes..
When i get records back the below c
Timer control causing error
I recently decided to add a timer control to an existing page that uses AJAX on my site. As soon as
PHP, jAVASCRIPT setting input values, why isn't it working?
Hi:
I am calling this javascript:
<script language="javascript">
Retrieving the 25 most recently added entries from all tables in a MySQL databas
Hello,
The code below works great. It creates a table that shows the 25 most recently added t
have trouble in a if condition
The if below is working ok, it check when indexes, name, zipcode and state are empty.
Code: &