Skip to main content

Posts

Showing posts with the label session

Has anyone created a PHP Session-like class in user code (not native)?

The native PHP Session functionality is great, but it's ultimately a singleton. There are times when you need to maintain state for multiple apps and in the scope of an already-started session (e.g. in an app framework). Technically one can stop/restart a session after changing session_name() , but this is impractical/impossible/unsafe within most apps. Using a shared session.save_path is also not an option if one app stores session data with a non-disk adapter.

Few questions about PHP sessions

I have a few a few question about php sessions: Since the default value for session.gc_maxlifetime is 24 mins then that means any session file that isn't modified for 24 mins will be deleted and the session will expire automatically.

Looping Through All a Server"s Sessions in PHP

Is there a way in PHP to get a list of all sessions (and the variables within each) on the server? Basically, we have a maintenance function which needs to know which users are currently logged into the site. We already store data for each user in a session variable, but I am hoping that I can loop through each of these sessions and pluck out the data I need. MY PHP is very limited (I am a .Net developer ussually) but if anyone knows if this is even possible (and how to do it) I'd be very grateful. I googled this, and the results I found tended to inidcate that it WASN'T possible, but I find this very hard to accept. Still, If you can't you can't but I thought my buddies on StackOverflow could give me a definitive answer! Source: Tips4all

Does storing large sessions slow down response time and server

I am in the process of creating a Facebook App for my website which includes functionality that requires the users friends list. Retrieving the friends is no problem, what I am struggling to decide, is how to store them. Option 1 - Store the users in my MySQL database, I have opted not to go for this as my database will become very heavy, very quickly. In addition, I will need to create a table for each individual Facebook user! Option 2 - Store the Facebook friends array in a session which is updated every half an hour to ensure new friends are included. Ignore the fact that the session updates every half an hour, is it a bad idea to store, what can be a very large array, within a session? The website is likely to be receiving high volumes of traffic, and will therefore be storing a lot of these sessions. Although I am an experienced developer, I am not overly experienced with sessions in these circumstances. I would simply like to know whether or not this i

what this error is due to session_start

My hosting sent me email saying I have set the session.save_path = /home/users/web/b1475/moo.youraccount/cgi-bin/tmp for your account then i found my website is giving me this error Warning: session_start() [function.session-start]: open(/home/users/web/b1475/moo.youraccount/cgi-bin/tmp/sess_718a8cd346244df6916f016eb315f19f, O_RDWR) failed: No such file or directory (2) in /hermes/waloraweb006/b1475/moo.youraccount/db.php on line 4 and the db.php code is (it is database connection file) <?PHP $conn = mysql_connect($host, $user, $pass); if ($conn) mysql_select_db($db, $conn); session_start(); ?> what can i do then to fix this error :(

Custom session handler in php using db

I am having problem with implementing custom session handler in php. The code: http://pastebin.com/9QV9f22Q I initialize this once in my frameworks bootstrap, after I have connection with db: require_once 'DbSession.php'; $session = new DbSession(); session_start(); But then I can't view my page. Firefox gets 302 Status with "Server not found" error. Firebug says that content is 5k long, but I can't view the page. Log after one reload: http://pastebin.com/JYe14nGR I wonder why it still "loses" that created DbSession instance. Do yo have any ideas? TIA

Do I need to write a custom session class for CodeIgniter?

I cannot seem to get CI's session library to function the way I want it to. Essentially, I am storing 2 different categories of data within the sessions. The data within the 2 categories may contain the same value. Right now my attempt to add a key => value pair to the session is failing, as it is only allowing 1 key => value pair to be associated with the array. It overrides itself each time I do a post. $arr = array( 'favorite_products' => array(), 'viewed_products' => array() ); $arr["favorite_products"][] = $fav_id; $this->session->set_userdata($arr); This is what the array looks when I print_r it: Array ( [favorite_products] => Array ( [4f1066c2b7fff] => 1648406 ) [viewed_products] => Array ( )) Am I doing something wrong, or is this just the way CI's session library works?