Hi everyone!
I need a global variable for each visitor,
that can be used in scripts around the site.
php $_SESSION array is perfect for that.
but I’m loosing session info on page changing in ModX (while the code works great in outer phps)
1. setting variable snippet:
<?php
if(isset($_POST['month'])){
session_start();
$_SESSION['day'] = $_POST['day'];
$_SESSION['month'] = $_POST['month'];
$_SESSION['year'] = $_POST['year'];
}
2. getting variable snippet
<?php
if(isset($_SESSION['month'])){
session_start();
$day=$_SESSION['day'];
$month=$_SESSION['month'];
$year=$_SESSION['year'];
}
else {
$day = date(d);
$month= date(m);
$year= date(Y);
}
echo "$day-$month-$year";
Both snippets are on every page.
I’m loosing all session info on page change.
If I refresh page - info stays.
caching is turned off, modx revo 2.0.4
are there any built-in opportunities to store that variable?