Whenever I try to use session_start()
[ at the very top of my file as it should be ] it gives me the following: This webpage is not available, which otherwise is not displayed when I do not use sessions. I would really appreciate any help.
Here is only a simple code for demonstration:
<?php
// Start the session
session_start();
?>
<!DOCTYPE html>
<html>
<body>
<?php
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
?>
</body>
</html>
i think It's the permission issue on the session folder. The start_session() failed to create session. to get the location of the sessions folder use the function sys_get_temp_dir():
<?php
echo sys_get_temp_dir();
after you found the location, if you are using Linux and Apache, you should change the group of the folder that you have founded
sudo chgrp www-data /the folder that you got from sys_get_temp_dir()/
Get or set your session path session_save_path()
session_save_path();
Maybe session is required permissions
Try it for permission
sudo chmod -R 775 /yoursessionpath
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.