session-variables

Session Variables do not get destroy even using session_destroy()

心已入冬 提交于 2019-12-20 06:39:59
问题 session_start(); $_SESSION['user'] = "789456"; $_SESSION['name'] = "dummy"; $_SESSION['id'] = "123"; print_r($_SESSION); session_destroy(); echo "Session End"; print_r($_SESSION); My output is: Array ( [user] => 789456 [name] => dummy [id] => 123) Session End :Array ( [user] => 789456 [name] => dummy [id] => 123) Shouldn't the output just be: Array ( [user] => 789456 [name] => dummy [id] => 123) If I use session_unset() before session_destroy() then I get the result I expect. Is it always

PHP session variable undefined

ぐ巨炮叔叔 提交于 2019-12-20 05:46:04
问题 I have this session variable which i am trying to set to an access level when the users logs in with this: $accessquery = mysql_query("SELECT roleid FROM person WHERE email = '". $email ."'"); $access = mysql_fetch_array($accessquery); $_SESSION['Access'] = $access; However it says that 'Access' is undefined, what is the problem? EDIT* if (($_SESSION['Access']) == "2") Error appears here EDIT* Session Start has been called. 回答1: Two possibilities here : Start the session by using session

Store variable using sessions

房东的猫 提交于 2019-12-20 02:54:30
问题 I have a variable which is updated on every page shift, but I want to store the value in the first call for good somehow. The variable is e.g $sizeOfSearch = $value['HotelList']['@activePropertyCount']; First time the page loads it's 933, on next page the same value is retrieved but it's now different e.g 845. This goes on page for page. What I want is to store 933 for good. So I can show this number on every page. Can I somehow store the first time this value is retrieved ? (I get the value

Clearing SESSION variables when a tab is closed

旧时模样 提交于 2019-12-20 02:46:20
问题 I need to clear the session variables when the tab is closed but I could not find any solutions so far. The closest I have got is by using the "onbeforeunload" function is javascript. <body onbeforeunload='destroySession()'> <!--Codes for the site includeing php scripts--> </body> <script type='text/javascript'> function destroySession(){ $.ajax({ url: "destroySession.php" }); } <script> The problem is the function is called every time a new link is clicked, refreshed or even if a form is

PHP: Notice: Undefined index where the session variable is defined

删除回忆录丶 提交于 2019-12-19 12:04:14
问题 I am making a registration system with an e-mail verifier. Your typical "use this code to verify" type of thing. I want a session variable to be stored, so that when people complete their account registration on the registration page and somehow navigate back to the page on accident, it reminds them that they need to activate their account before use. What makes this problem so hard to diagnose is that I have used many other session variables in similar ways, but this one is not working at

Symfony2: How to save a session attribute as a custom field on DB, with a custom PdoSessionStorage?

时光怂恿深爱的人放手 提交于 2019-12-19 08:53:34
问题 I have a custom class extending PdoSessionStorage, but I don't know how to catch attributes from the session to save them as independent fields in the database. Other posibility is to unserialize session data in sessionWrite($if, $data) method of my custom PdoSessionStorage Class. But I don't know how to unserialize the $data string to get only data I want to. I tried this: unserialize($data); and this throw me the follow error: Fatal error: Uncaught exception 'ErrorException' with message

INFO output despite “SET client_min_messages TO WARNING” just before

本小妞迷上赌 提交于 2019-12-19 05:59:45
问题 postgresql-9.0.15 on CentOS 6.5. I have a plperlu function that outputs an INFO message. I want to suppress it during testing (using psql, which also behaves as below), but I can't even seem to do it from a pgAdminIII (1.18.1 for win2003) query window: SET client_min_messages TO WARNING; select my_info_outputting_function('lalala') I run that and look in the "messages" tab, and there's my INFO message. (This may appear similar to How to suppress INFO messages when running psql scripts , but I

How to store variable in session codeigniter

若如初见. 提交于 2019-12-19 03:14:26
问题 I would like to store the variable in the session currently i am tryin like this but not working. In Controller <?php session_start(); $_SESSION['myvar']='myvalue'; ?> 回答1: Simple : First, load this library $this->load->library('session'); Then, to add some informations in session : $newdata = array( 'username' => 'johndoe', 'email' => 'johndoe@some-site.com', 'logged_in' => TRUE ); $this->session->set_userdata($newdata); Next, if you want to get values : $session_id = $this->session-

Can't detect whether Session variable exists

落花浮王杯 提交于 2019-12-18 20:05:15
问题 I'm trying to determine if a Session variable exists, but I'm getting the error: System.NullReferenceException: Object reference not set to an instance of an object. Code: // Check if the "company_path" exists in the Session context if (System.Web.HttpContext.Current.Session["company_path"].ToString() != null) { // Session exists, set it company_path = System.Web.HttpContext.Current.Session["company_path"].ToString(); } else { // Session doesn't exist, set it to the default company_path = "

Windows Phone 7 Silverlight using session

≡放荡痞女 提交于 2019-12-18 18:31:15
问题 I am creating a Windows 7 mobile Silverlight project. I use Rest api for authentication using a class say Authentication . I get an authentication token as a response and I assign it to a class property AuthToken because I need to use this in different places. Is there any way to store this AuthToken in session or any thing else. Because I did not find any session example in wp7. Thanks 回答1: You're not finding any session examples because WP7 doesn't have session as far as I know. You should