Jump to content

sessions


boo_lolly

Recommended Posts

i'm building a small CMS to be integrated with a third party shopping cart... this CMS is a bridal registry, with admin and public pages. the admin adds products to a bridal registry using the admin pages... then, the public can view a registry that has products that the admin pulled from the shopping cart database... and then purchase an item from the registry.

the difficulty involved comes from how crazy this third party shopping cart is... it's extremely difficult to work with, and confusing... it's weird, when you click 'Add to cart', you are taken to the shopping cart page, and the correct item is in the cart... but NONE of the rest of the information gets sent (unique id's, registry id's...ect...). it's so weird i have no idea how to make it work... so, i was thinking about FORCING information to be sent from page to page... then i came across sessions...

i guess what i'm asking is can sessions help my current situation? i just need to pass along a few values for a few variables for each individual public user... i'm pretty sure sessions can do this for me, but i have no idea where to start.. does anybody have any tips, code examples, explanations, anything that can get me on my way??? thanks in advanced.

-boo
Link to comment
Share on other sites

yes, they can help you.
I worked up this on my site, www.freelancebusinessman.com
under tutorials, there is a tutorial for this, it's a little outdated, as far as compared to my current knowledge, and is probably due for another rewrite in a few months.
I will probably rewrite the whole thing, and triple the information in it, but it will give you a basic idea of how everything works, come back here afterwards if you have any more questions.
Link to comment
Share on other sites

wow business, great site, and great tutorial! i am definitely more familiar with sessions after reading it. i have a question... since the shopping car has it's own session... should i add another one for this registry? or should i be able to use the shopping cart session WITH the registry? that would be best...

either way, i am curious to see if more than one session can even be called on the same page... and what you would be afforded by doing so, if possible...
Link to comment
Share on other sites

thanks roopurt. i was wondering, is it possible to have a nested session array? for instance... if i have multiple values for $_SESSION['price']... is it possible to add an index to this session? or would i be adding on an index to the array $price, and then storing the $price array as a session array $_SESSION['price']?

$price = array(12, 41, 15, 22, ... ect...);

$price = array(12, 41, 15, 22, ... ect...) ... add another index to the array....

$_SESSION['price'] = $price

is this possible? and how do i "append" to an array another index and store associative values in this new index??
Link to comment
Share on other sites

Yes you can have arrays in a session array. You can even put objects in there. It functions just like any other array, only it's data is available to you across the site (with enabled sessions of course). What you did was correct for adding another array to the $_SESSION['price'] key. So you could do
[code]
<?php
$_SESSION['moreprices'] = array('something', 'else', array('and', 'again'));
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.