How to keep session unchanged in codeigniter? - codeigniter

I'm trying to create a shopping cart by storing the cart in a table in a database, instead of using the built-in CI cart class. I use sessionID to identify one visitor from another. But I found that the sessionID is changing for a period of time, even the visitor doesn't close the browser.
Is this a normal behavior of CI to renew the sessionID for a short period of time? Is there a way to make it unchanged until the visitor close the browser?
Thank you at advance.

Also, make sure in your config file you have cookie_prefix set.. see bottom of: http://ellislab.com/codeigniter/user_guide/libraries/sessions.html

If your session is contstantly being reset using the CI Session library, make sure the cookie domain is set to something like:
$config['cookie_domain'] = '.mysite.com'; // the . is for a wildcard subdomain

Related

Session handling between Laravel and Vue for a shopping cart

I have a Laravel Vue application. The goal is to build a shop. Frontend and backend run on the same server. I don't use any authentication (so no registration etc.). Nevertheless I want to start a session for the user as soon as he comes to the website. So that the shopping cart of the respective user remains saved.
The workflow is roughly clear to me. I haven't really found anything specifically for this case. But I think that it is not only me. That's why I'm asking you. Could you please outline the process here. I use POST, GET, PUT and DELETE methods for manipulating the shopping basket.
Thanks a lot!
i dont know if i got your question right or not but in my case if i worked on shopping cart i have two method to save data the first one is to use vuex to store data but if i need this data to be exist if i refresh the browser i will use localStorage as it's exist for purpose like this or i will use reddis and each time the user add something to cart i will add it to reddis and when he remove it i will remove it from it

Session is expired when working on two different projects at same time

I have two projects of sugarcrm installed on my local server, nothing wrong with that.
Now I start my first project i.e. sugarcrm in the browser, login with the credentials, and after that when I opened the second project i.e. demo_sugarcrm in the browser and login, my sugarcrm session is expired.
And same with the demo_sugarcrm also. Its session expired when I login to the sugarcrm
What is going on here, I have totally different database of both. they dont share anything except that both are on local sever.
I think adjusting unique_key is supposed to fix this, but as an alternative you could modify /etc/hosts such that 'sugarcrm' and 'demo_sugarcrm' hostnames both reference 127.0.0.1. Then you could visit http://sugarcrm and http://demo_sugarcrm. I'm sure any shared cookie mayhem would go away at that point since the browser would consider these to be distinct sites.
I believe that if you edit config.php and change the unique_key variable to be different between the two instances then you shouldn't get kicked out anymore.

Magento multi-domain checkout issues

I have a Magento install with multiple domains (domain1.com, domain2.com) sharing a single checkout URL (checkoutdomain.com). The problem is when I proceed to cart and do to the new domain I get "no items in shopping cart" error. For some reason the session/cookies aren't being passed to the checkout domain.
I'm running Magento 1.7. I've gone to system/config/web/session cookie management and tried all of the following values in the cookie domain field:
.domain.com
.domain.com/
http://www.domain.com
http://www.domain.com
Should something else go here?
I also have cookie path field blank (default) and use http only set to yes (default).
I'm not sure what else to do here.
The first place I'd check is your store setup. Remember that you can't easily share a cart across multiple Websites, only Stores and Store Views (to use Magento's nomenclature).
Assuming that's fine, your next problem is ensuring that all of the domains use the same PHP session. You can do this by telling them all to use the same session id. Cookies are an ideal solution for this, but cookies do not work across completely different domains.
This means we have to explicitly tell checkoutdomain.com to session that we wish to load. We can force Magento to load a specific session by passing the session id as the SID GET parameter. You can get this value by calling Mage::getModel("core/session")->getEncryptedSessionId().
You should set web/session/use_frontend_sid to yes in your system configuration.
You should also keep in mind that not specifying a cookie path will make it default to the current path you are on when the cookie is set. You should default it to "/" to make sure it is being set globally for the site.

Magento session lost when switching to https from http

I've searched high and low for a solution to this, with no luck. My host told me they are too busy to help.
Magento 1.4.2 // SSL cert
1- When I add an item to cart, the page reloads and my item is added to cart. [good]
2- Next, I click home, and my items are no longer visible in cart sidebar. [bad]
3- Next, I click "Tops", and my items are still not visible in cart sidebar. [bad]
4- Next , I click "Bottoms" and the items show just fine.
In all cases where the cart isn't visible, I can add https to the URL and the cart loads up just fine. Can anyone help me figure out why my session is being lost between http and https?
I have all my backend web cookie settings set to "no" except for sID.
Also- When a user is logged in, the cart items ALWAYS show on the right. It's only screwy if they're a guest.
Thanks guys, if you need me to post any code let me know.
wwwdotlylifdotcom
EDIT: Here is a screenshot of my cookies session in firebug (not exactly sure what I am looking at). Hope this helps.
And here is my Session settings in magento: I have tried just about every variation of turning these on and off.
EDIT!
This issue has actually been narrowed down to a cache issue. We found out that when the cache is dumped/deleted, the website works properly. But after a few minutes of surfing the problem happens again. Does anyone have any idea? (And should i change the question title?)
I'm using a module called Lightspeed from TinyBrick, and it seems the new cache options are messing with our site. =( I'm contacting them shortly.
**EDIT Tinybricks excellent support helped us out. Thanks for all of your suggestions.
Is the session cookie being set to be HTTPS-only? That'll prevent it from being carried over to regular HTTP requests, effectively giving the user two different sessions.
You have in your screenshot two frontend cookie with two domains, one with www and an other one without. Check if you have a correct domain name in the configuration > Web tab > Cookie Management > Cookie Domain (or something close to that). If it's empty set it to ".mydomain.com" and try again.
Check if you don't have different cookie domain in your configuration in the other store views, set them to "use website".
If still doesn't work, What are the values of the fields of cookie management and the cookie validation settings
We were experiencing similar issues where our custom nav (depending on whether a user was logged in or not, was not very consistent across different pages.
We followed the suggestion # http://ka.lpe.sh/2011/06/19/magento-checking-customer-admin-is-logged-in-or-not/ to check if a user was logged base on the frontend session variable before a rendering a particular block, and it seems to have done the trick.
Perhaps you can try something similar.
Tinybricks excellent support helped us out. Thanks for all of your suggestions. This was a localized problem based off cache and a module called Lightspeed.

Magento ignores extra URL parameters set

I am trying to open a Magento store link from an external site. While opening the store link I need to send some information using the query string parameters.
So I open a link (through php code) such as:
http://magentostore.com/myproduct.html?id=3434&user=445
However the Magento store link ignores the query string parameters and reloads the page as:
magentostore.com/myproduct.html
I checked in Firebug and can see that there was a redirect to the Magento store without the query string parameters. Is there a way to override this behavior and let Magento load with the query string parameters?
What setting can I do in the Magento store to let it allow using the query string parameters?
Is there any other way of sending some more information to the Magento store page?
Is there a way to find out if its Magento doing this and not the server?
Thanks
Magento is receiving the queries on the first request but redirects to the URL it has in the URL Rewrite list. This is probably for SEO reasons. Whatever code you have that needs those values should store them in a session variable before the redirect happens.
deveffort says:
I researched for the URL rewrites and looks like there was a URL redirect for the product link! I have removed it and have my scenario working. However would be great to know if there is anything that can be done to make sure the Magento code does not do any query string parameter sanitization. Thanks a lot..
clockworkgeek says:
I fear removing that rewrite is temporary. It will replace itself on the next product re-index or perhaps when the product is saved. Since you only want to set some cookies it needn't be done by javascript, that is less reliable anyway.
Instead, create an observer to watch for an event of catalog_controller_product_view. Have the observer check for the query parameters, and if the correct one exists, set the cookie. Also it might try checking the referrer URL matches what you expect of it, that might make spoofing the values a little harder.

Resources