开发者

Can $_session data be set in a function

开发者 https://www.devze.com 2022-12-21 20:55 出处:网络
I have this code in a function $_SESSION[\'id\'] = $id; $_SESSION[\'pineapple\'] = $hashbrown; $_SESSION[\'username\'] = $username;

I have this code in a function

$_SESSION['id'] = $id;
$_SESSION['pineapple'] = $hashbrown;
$_SESSION['username'] = $username;

However, the session data never gets set, even on the initial page. Can sessions be edited though a function or not?

info on cookies/ect

this is the code for starting the session

<!--开发者_StackOverflow社区 a bunch of info about versions and build goals ect -->
<?php include "loader.php";?>
<!--some more comments -->

loader.php

<?php
// Load Core functions and initalise enviroment
session_start();
include "../music/php/logic/core.php";
include "../music/php/logic/secure.php";
include "../music/php/logic/forms.php";
openDatabase ($set_host, $set_username, $set_password, $set_database);
$core = getCoreSettings ($set_prefix);
and so on...

loader.php initalises everything and includes the right page script.

I don't set any cookies explicitly, and this is what print_r($_COOKIE); produces:

 [SQLiteManager_currentLangue] => 2


Can sessions be edited though a function or not?

Yes they can, $_SESSION is a superglobal.

Have you initialized a session using session_start()?


You should call session_start() in each of your PHP scripts, where $_SESSION array uses

0

精彩评论

暂无评论...
验证码 换一张
取 消