» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-22-2006, 12:59 PM
euhoria euhoria is offline
Junior Member
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
euhoria is on a distinguished road
Default session variable overwriting

Hi,

i want to store a value in session array everytime page is called.

I am doing it like

PHP Code:
session_start();
$name = $_GET['name'];
$_SESSION[] = $name;

I am assuming that everytime page is loaded it will store name value automatically to the next index of session array, for example


PHP Code:
$_SESSION[0] = ist load
$_SESSION[1] = 2nd load
$_SESSION[2] = 3rd load



but it is overwriting the value at index 0 on every call like this,

PHP Code:
$_SESSION[0] = ist load //output array

$_SESSION[0] = 2nd load //output array

$_SESSION[0] = 3rd load //output array


and output array contains only one index 0 with the new value.

how can i store new values to next index of session array on every page call? -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-22-2006, 01:00 PM
graham graham is offline
OSP Starters
 
Join Date: Aug 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
graham is on a distinguished road
Talking

PHP Code:
session_start();
$_SESSION['arrayname'][] = $_GET['name'];



It's a bad idea to use a superglobal like $_SESSION like an array of your own. -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  #3  
Old 08-22-2006, 01:01 PM
alexis alexis is offline
OSP Starters
 
Join Date: Apr 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
alexis is on a distinguished road
Default

try using some kind of counter like this

PHP Code:
$i = 0;
$i++;
$_SESSION[$i]['whatever'] = 'whatever'; -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
clear session variable vandort ASP forums and Tips 1 08-11-2006 01:48 PM
Security Safe PHP Session Setup waugh PHP Programming and Tips 2 08-03-2006 05:03 PM
New session not generated furious PHP Programming and Tips 1 08-01-2006 04:51 PM
assigning a session variable.... kingfisher ASP forums and Tips 1 06-23-2006 01:59 PM
stop indexing PHP SESSION IDs danielle Yahoo 4 03-26-2006 05:34 AM


All times are GMT. The time now is 03:48 AM.