Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php session array

 session_start();
 $_SESSION['name_here'] = $your_array;
Comment

session array

<?php

//Start your session.
session_start();

//Add a product ID to our cart session variable.
$_SESSION['cart'][] = 2787376;

//Dump it out for example purposes.
var_dump($_SESSION);


//how to access it
<?php

//Start your session.
session_start();

//Make sure that the session variable actually exists!
if(isset($_SESSION['cart'])){
    //Loop through it like any other array.
    foreach($_SESSION['cart'] as $productId){
        //Print out the product ID.
        echo $productId, '<br>';
    }
}
Comment

array session

<?php
$my_arr = array('Saumya', 'Nikita', 'Upasana', 'Dyana');
// use array_push to add 3 elements to end of $my_arr
$new_num = array_push($my_arr, 'Adhikar', 'sanjay', 'Puspendra', 'Mukesh');
// inspect return value of array_push
echo $new_num;
print_r($my_arr);
?>

//my ex

$id = $_GET['PId'];
                                // $cartArray = array(
                                  
                                // );
                               // array_push($cartArray, $id);
                                session_start();

                            // $_SESSION["cart"] = $cartArray;
                             $_SESSION['cart'][] = $id;

                             header("Content-type:application/json");
                             echo json_encode($_SESSION["cart"]);
Comment

how can I reach session array in javascript

<input type="hidden" id="sess_var" value="<?php echo $_SESSION['is_logged']; ?>"/>
Comment

how can I reach session array in javascript

var session = document.getElementById('sess_var').value;
alert(session);
Comment

PREVIOUS NEXT
Code Example
Php :: change default route laravel 
Php :: php language is used for 
Php :: PHP OOP - Destructor 
Php :: theme mod disalow wp 
Php :: php if in database field exists, if exists update, if not create 
Php :: How I can generate the unique transaction ID in laravel 8 
Php :: PHP sha1 — Calculate the sha1 hash of a string 
Php :: remove duplicate characters in a string in php 
Php :: wp wc php edit archive-product category page 
Php :: Skip model mutator 
Php :: laravel queue work schedule cpanel 
Php :: Use external variable in array_filter 
Php :: intellisense in visual studio code for php-oop 
Php :: twig render string 
Php :: laravel firstorcreate usage 
Php :: Laravel Secured Password 
Php :: laravel copy image 
Php :: laravel validation two columns unique 
Php :: laravel websockets 
Php :: xss=removed 
Php :: php insert char before each letter using regex 
Php :: php inverse / arc cosine 
Php :: php const in class 
Php :: Sending HTML Code Through JSON 
Php :: where to add browscap php 
Php :: Allowed memory size of 33554432 bytes exhausted (tried to allocate 8192 bytes) 
Php :: htaccess after trailing slash page return status 200 
Php :: * * * * * cd /path-to-your-project && php artisan schedule:run /dev/null 2&1 
Php :: php enablem mod 
Php :: laravel check model column was changed 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =