session-variables

store mysqli_query result in session

最后都变了- 提交于 2019-12-02 05:01:43
I want to store the result of a MySQLi query as a session variable so that I can reuse it without executing the query again. I don't want to execute the same query on every page of my website or every time a page is refreshed. I've tried the code below, but I get errors like "object can not be stored in session" and "mysqli_fetch_array expects parameter one to be a resource". How can I store the query result in a session? session_start(); if (!isset($_SESSION['query_result'])) { $anything=mysqli_query($connection,"select something from table name where filed1='$variable' order by id desc limit

Session variables not accessible in subdirectory

若如初见. 提交于 2019-12-02 03:39:15
问题 When we moved our project from the beta test server to our live server we experienced the following: Session variables are only accessible if the file accessing them is in the same folder as the file that created them. This was not the case on our beta server. So I've created three very simple test files: test.php <?php session_id("581186accf44d7e80df40d0b5a47fb7d"); session_start(); $_SESSION['myvariable'] = 'Hello World'; ?> <html> <body> <p><a href="page2.php">Same folder test</a></p> <p>

Access Symfony session values from external application

岁酱吖の 提交于 2019-12-02 01:40:05
I have a third party application ( responsivefilemanager plugin for TinyMCE ) that I can't re-write it using Symfony2 . I need to protect it against unauthorized users. Is it possible to access Symfony2 's session variables (user, roles , etc) from external application? How? I tried to do session_start() and read $_SESSION variable, but it is empty! My config.yml is: imports: - { resource: parameters.yml } - { resource: security.yml } - { resource: @ar1y4nArticleBundle/Resources/config/admin.yml } framework: #esi: ~ translator: { fallback: %locale% } secret: %secret% router: resource: "%kernel

How to delete data based on value in session variable

橙三吉。 提交于 2019-12-02 01:08:49
add.php(When user click add photo) <div class="col-lg-12"> <div class="form-group" id="image"> <label>Auction Image</label> <div action="uploadImages.php" class="dropzone" id="uploadImageForm"></div> <span class="help-block" id="image-error"></span> </div> </div> <script> $(function () { Dropzone.options.uploadImageForm = false; Dropzone.options.uploadImageForm = { paramName: "file", maxFilesize: 1, acceptedFiles: 'image/*', maxFiles: 5, dictDefaultMessage: '<img src="images/icon_images.svg" width="100"/><br/><br/>Drop auction image here', addRemoveLinks: true, removedfile: function(file) {

Session variables not accessible in subdirectory

强颜欢笑 提交于 2019-12-02 00:54:59
When we moved our project from the beta test server to our live server we experienced the following: Session variables are only accessible if the file accessing them is in the same folder as the file that created them. This was not the case on our beta server. So I've created three very simple test files: test.php <?php session_id("581186accf44d7e80df40d0b5a47fb7d"); session_start(); $_SESSION['myvariable'] = 'Hello World'; ?> <html> <body> <p><a href="page2.php">Same folder test</a></p> <p><a href="test/page2.php">Subfolder test</a></p> </body> </html> Then we have the following file

Can I store a Scripting Dictionary in a session variable?

十年热恋 提交于 2019-12-01 23:37:39
I have a classic ASP site where I create a dictionary when the user logs in and then stores that dictionary in a session variable like so... dim objDict set objDict = server.createobject("scripting.dictionary") ' processing here to fill dictionary set session("user") = objDict That all works fine and dandy but when I navigate to another page and try to access a value from the stored dictionary like this... session("user").item("id") I get the following error... error '80020009' Can anyone tell me if I'm accessing the stored dictionary incorrectly? Is storing the dictionary object in a session

Clearing SESSION variables when a tab is closed

这一生的挚爱 提交于 2019-12-01 22:24:53
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 submitted. Is there a better way to destroy session variables on closing a tab or am I doing something

Use variable set by psql meta-command inside of DO block

大兔子大兔子 提交于 2019-12-01 21:35:39
Here's what I would like to do: \set values foo,bar,baz DO $$ DECLARE value TEXT; values TEXT[] := string_to_array(:'values', ','); BEGIN FOREACH value IN ARRAY values LOOP raise notice 'v: %', value; END LOOP; END $$ LANGUAGE plpgsql; Which results in the following error: ERROR: syntax error at or near ":" SELECT string_to_array(:'values', ',') INTO values... ^ Here's the solution I have currently, but it feels hacky: \set values foo,bar,baz PREPARE get_values AS SELECT string_to_array(:'values', ','); DO $$ DECLARE value TEXT; values TEXT[]; BEGIN EXECUTE 'EXECUTE get_values' INTO values;

Expanding environment variables for command prompt

一曲冷凌霜 提交于 2019-12-01 21:27:52
I would like to run a cmd.exe that would evaluate environment variables at call time instead of when it parses the command. If I set the BASE to 2 and echoing it, I should see the number 2, although running this script does not properly set the base. Expected Behavior: C:\Users\schristo>cmd.exe /X /C "set BASE=2 && echo %BASE% && pause" 2 Press any key to continue . . . Actual behavior: C:\Users\schristo>cmd.exe /X /C "set BASE=2 && echo %BASE% && pause" %BASE% Press any key to continue . . . This should work for you: cmd.exe /X /V:ON /C "set BASE=2&&echo !BASE!&&pause" /V:ON enables Delayed

Is it possible to set localStorage or Session variable in asp.net page and read it in javascript on the other page?

南楼画角 提交于 2019-12-01 18:21:55
As in question. Is it possible to set variable in asp.net page in localStorage and retrieve it on the other page? How to set localStorage variable in asp.net. Is it possible? After that I could read variable using: localStorage.getItem('UserID'); I guess You can't. The whole point of local storage is that it is local and You can manipulate it only from javascript. If You need to pass values between server and client You need to use some transport technology - cookies, ajax calls, hidden fields etc. It will all depend on how your application is organized, what kind of information is being