This is my script in other additional script.
______________________________________________________
<?php
session_start();
if (isset($_SESSION['id'])) {
echo $_SESSION['id'];
}
?>
________________________________________________________
i do not understand why the session is not readable.
this is my login script.
___________________________________________________________
<?php
//session_start();
// Load the settings from the central config file
require_once 'config.php';
// Load the CAS lib
require_once $phpcas_path . 'CAS.php';
// Enable debugging
phpCAS::setDebug();
// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0, 'cas.poliupg.ac.id', 8443, $cas_context);
phpCAS::handleLogoutRequests(true, "cas.poliupg.ac.id");
phpCAS::handleLogoutRequests();
phpCAS::setNoCasServerValidation();
// force CAS authentication
phpCAS::forceAuthentication();
// at this step, the user has been authenticated by the CAS server
// and the user's login name can be read with phpCAS::getUser().
//phpCAS::handleLogoutRequests(true, array("cas.poliupg.ac.id"));
// logout if desired
if (isset($_REQUEST['logout'])) {
phpCAS::logout();
session_destroy();
}
$_SESSION['id'] = session_id();
$_SESSION['username'] = phpCAS::getUser();
if (isset($_SESSION['id'])) {
// echo "<script language=\"JavaScript\">{ location.href=\"index.php\";
self.focus(); }</script>";
echo $_SESSION['id'].'</br>';
echo $_SESSION['username'].'</br>';
}
?>
______________________________________________________________________
in this login script, I try to print my $_SESSION['id'] variable after i
login in cas server through phpCAS client.
and it works. the session is readable.
so i think the session variabel works. but. when i show in the others
simple page like above. it is not readable even i append session_start
script.
thank you very much for your help Sir.
Best Regards
Andi Zulfadli
2015-07-23 12:56 GMT-07:00 Neil Sabol <[email protected]>:
> Hi Andi,
>
>
>
> I am not an expert, but it looks like you may be missing
> “session_start();” in your code to create the PHP session.
>
>
>
> Hope that helps.
>
>
>
> Thanks,
>
> -Neil
>
>
>
> *From:* Andi Zulfadli [mailto:[email protected]]
> *Sent:* Thursday, July 23, 2015 1:36 PM
> *To:* [email protected]
> *Subject:* [cas-user] Using session_id() variabel as Global Session
> variable.
>
>
>
> Dear Master.
>
> Please Your Help.
>
> I am using phpCAS Client 1.3.3 with simple authentication to CAS server
> with LDAP backend.
>
> and i have successfull authentication and get return ticket / session id
> variabel. ex: "ST-404-sKkVIrpxuedp52YOtjGs-caspoliupgacid"
>
> my problem is, i want to use the ticket / session id variabel as global
> session variabel and use the session for build other page in my application.
>
> I do not know what the cause why in other pages session is not readable.
>
>
>
> plese your help.
>
> Thank you.
>
>
> My "index.php" Code :
>
> _________________________________________________________________________
>
> // Load the settings from the central config file
>
> require_once 'config.php';
>
>
>
> // Load the CAS lib
>
> require_once $phpcas_path . 'CAS.php';
>
>
>
> // Enable debugging
>
> phpCAS::setDebug();
>
>
>
> // Initialize phpCAS
>
> phpCAS::client(CAS_VERSION_2_0, 'cas.poliupg.ac.id', 8443, $cas_context);
>
>
>
> phpCAS::handleLogoutRequests(true, "cas.poliupg.ac.id");
>
>
>
> phpCAS::setNoCasServerValidation();
>
>
>
> // force CAS authentication
>
>
>
> phpCAS::forceAuthentication();
>
>
>
>
>
> // logout if desired
>
> if (isset($_REQUEST['logout'])) {
>
> session_destroy();
>
> phpCAS::logout();
>
> }
>
>
>
> // for this test, simply print that the authentication was successfull
>
>
>
> $_SESSION['id'] = session_id();
>
> $_SESSION['username'] = phpCAS::getUser();
>
> $_SESSION['name'] = session_name();
>
> $_SESSION['version'] = phpCAS::getVersion();
>
> _________________________________________________________________________
>
>
>
>
>
>
>
>
>
>
>
> --
>
> You are currently subscribed to [email protected] as: [email protected]
>
> To unsubscribe, change settings or access archives, see
> http://www.ja-sig.org/wiki/display/JSG/cas-user
>
> --
> You are currently subscribed to [email protected] as:
> [email protected]
> To unsubscribe, change settings or access archives, see
> http://www.ja-sig.org/wiki/display/JSG/cas-user
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "jasig-cas-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jasig-cas-user/CtDFf4fPs8w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You are currently subscribed to [email protected] as:
[email protected]
To unsubscribe, change settings or access archives, see
http://www.ja-sig.org/wiki/display/JSG/cas-user