|
Hello, i've implemented this custom PHP Session Class for storing sessions into a MySQL database:
class Session { private $_session; public $maxTime; private $database; public function __construct(mysqli $database) { $this->database=$database; $this...
Started by Gianluca Bargelli on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Var_dump(session_id()); if (session_id()=="") { if ($_GET["sessionid"]) { session_id($_GET....
Maybe you need to start a session first?
I have had it before where sessions don't seem to persist and if not set it manually.
|
|
Are there any reasons not to want to use a multi dimensional SESSION array to store temporary user data?
Started by chris on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Of course, a deep multi-dimensional array may cause a performance hit too of data, it should make negligible performance....
Personally, I'm a fan of creating a Session class before storing.
array, as it just gets serialized to a string.
|
|
How can you see the assigned value of the following SESSION variable?
I run the following after start_session()
$_SESSION['login']['email'] = "ntohuh";
I get after printing with print_r($_SESSION);
( [login] => Array ( [email] => )
This question...
Started by Masi on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
This is what I did, if it helps:
# This empties $_SESSION $_SESSION($_SESSION); echo '....
array(); session_start(); $_SESSION['login']['email'] = "ntohuh"; echo '<pre>'; print_rThe value shows up for me.
|
Ask your Facebook Friends
|
I am storing shopping cart data in a SESSION Array like this:
$_SESSION['cart'][$sessID] = array ('quantity' => 1, 'price' => $prodPrice, 'prodName' => $prodName, 'size' => $size, 'handle' => $handle)
Each time a user adds an item to the...
Started by VCM on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
'])
If it can be empty:
$items_in_cart = is_array($_SESSION['cart']) ? count($_SESSION['cart']) : 0
If I understand the question correctly you're looking for count()
count($_SESSION['cart'])
If you are sure $_SESSION....
|
|
Is it possible to make an array a session variable in php. The situation is I've a table(page 1) with some cells having a link to particular page. The next page will have a list of names(page 2 which I want to keep in session array) with their respective...
Started by Anurag on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Yes, you can put arrays in sessions, example:
$_SESSION['name_here'] = $your_array;
Now you can use(); $_SESSION['name_here'] = $your_array;
Possible Example:
session_start(); $_SESSION['name_here....
|
|
Hey all,
im having some problems with jagged arrays stored in session for ASP.net i have some code which creates a jagged array, them populates, and then stores this populated jagged array into session
protected string[][] answersJArray; answersJArray...
Started by c11ada on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
First declare a jagged array variable and cast it from the session variable like so:
string[][] answersJArray = (string[][])Session["answersJArray"];
Then you can loop through the array like you were].ToString()); }
Shouldn....
|
|
Below is a php code that is used to add variables to a session.
<?php session_start(); if(isset($_GET['name'])) { $name = isset($_SESSION['name']) ? $_SESSION['name'] : array(); $name[] = $_GET['name']; $_SESSION['name'] = $name; } if (isset($_POST...
Started by LiveEn on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Or unset($_SESSION['variableName']);
Try this one:
if(FALSE !== ($key = array_search($_GET['name'],$_SESSION['name']))) { unset($_SESSION['name'][$key]); }
Currently you are clearing the name array, you($_POST['remove....
|
|
Using a user model which returns an array that looks like this:
$user_data['display_name'] = "John Doe"; $user_data['avatar'] = ./images/user144.jpg";
i create my session using $this->session->set_userdata('user_data',$user_data);
now if on another...
Started by lock on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
If (!is_array($this->session->userdata('abc'))){ //...and if it's not - set it to a blank array $this->session->set_userdata('abc',....
Image01.png'); //Check to see if the session is currently populated.
|
|
Hey.
I want to count my $_SESSION['cart'] (units) products from my basket.
#check added stock $units = (int) $_POST['units']; $sizes_id = (int) $_POST['size_id']; $in_stock = $db->GetScalar("SELECT p.units FROM products_sizes s INNER JOIN products ...
Started by william on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Ok here goes
<?php $total_units = 0; foreach ($_SESSION['cart'] as $key => $value) { $total.
|
|
I'm a designer who dabbles in scripting using JQuery and PHP. I have a pretty good understanding of functionality in both but using sessions is new to me.
I have an app with a search feature. The search results may stretch over several pages and each ...
Started by Marcus on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
First off, you can use the php function implode()....
Then the array will automatically be turned into a JavaScript array.
Do a json_encode($_SESSION['idsArray']) then you can fetch that with $.ajax() and set the dataType to 'json'.
|