I'm trying to save a url in a session variable so when I go to a new page, that url is available.
Here's what I'm doing. Note that this is an ExpressionEngine template and PHP is allowed and parsed before any javascript is sent to the browser.
Any session storage should take place when the PHP is parsed.
// if I place session_start() here, I get Session already started error
var REGISTER_URL = '{site_url_https}register/';
function logon_or_signup() {
<?php
echo "// setting session info"."\n";
$_SESSION['returnURL'] = "{site_url_https}/schedule";
// it echos out perfectly at this point
echo "//".$_SESSION['returnURL']."\n";
?>
window.location = REGISTER_URL;
}
Now in the REGISTER_URL page:
<?php
session_start(); // don't get Session already started error here.
echo "//".$_SESSION['returnURL']."\n"; // Getting undefined Index returnURL here
if(isset($_SESSION['returnURL'])) {
echo " <input type=\"hidden\" name=\"returnURL\" id=\"returnURL\" value=\"".$_SESSION['returnURL']."\" />";
} else {
echo " <input type=\"hidden\" name=\"returnURL\" id=\"returnURL\" value=\"/\" />";
}
?>
It just isn't working between the pages. Session values from phpinfo():
Session Support enabled
Registered save handlers files user mm
Registered serializer handlers php php_binary
Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly On On
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file /dev/urandom /dev/urandom
session.entropy_length 16 16
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 5 5
session.hash_function 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path /var/lib/php5 /var/lib/php5
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies On On
session.use_trans_sid 0 0
Any ideas on how to fix this?