jaymc Posted November 11, 2008 Share Posted November 11, 2008 I need a function that can unserialize the contents of a session file so I can manually alter a value Then, I need to save the file This cant involve any session_start() etc as I dont want to over write the real session I would prefer to do it all raw Cheers Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/ Share on other sites More sharing options...
jaymc Posted November 11, 2008 Author Share Posted November 11, 2008 session_decode doesnt appear to work. Checked into it and appears to be because of the use of a pipe | of which my session files have Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688083 Share on other sites More sharing options...
flyhoney Posted November 11, 2008 Share Posted November 11, 2008 you could json_encode() / json_decode() the session. Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688090 Share on other sites More sharing options...
wildteen88 Posted November 11, 2008 Share Posted November 11, 2008 PHP uses the built in serialize/unserialize functions when writing/reading data to the session file. Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688092 Share on other sites More sharing options...
jaymc Posted November 11, 2008 Author Share Posted November 11, 2008 You cant use those functions to read the raw php session file.. it contains etc bits Does anyone know of a function to perform this action Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688122 Share on other sites More sharing options...
kenrbnsn Posted November 11, 2008 Share Posted November 11, 2008 Why do you want to mess with the sessions files outside of the normal methods? Ken Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688135 Share on other sites More sharing options...
jaymc Posted November 12, 2008 Author Share Posted November 12, 2008 When someone sends someone else a message I want to flash a box saying new message However, I dont want to query the database every page refresh, I called SESSIONs on every page so it makes sense to manipulate them.. I need it this way Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688147 Share on other sites More sharing options...
DarkWater Posted November 12, 2008 Share Posted November 12, 2008 Querying the database would probably more efficient than low-level handling of the session files. In fact, I've actually never seen that done in my entire time as a PHP developer and I personally think it's just silly. Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688159 Share on other sites More sharing options...
jaymc Posted November 12, 2008 Author Share Posted November 12, 2008 the messages table has 500,000 rows of data, even with index.. if its getting hammered by 1000s of users id rather find another way.. Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688161 Share on other sites More sharing options...
DarkWater Posted November 12, 2008 Share Posted November 12, 2008 Clear out messages that a certain number of days old. Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688164 Share on other sites More sharing options...
jaymc Posted November 12, 2008 Author Share Posted November 12, 2008 yeh, but still, it accumulates 100,000's rows it doesnt make sense to me to have to query that table every time you flick between a page It will just hammer it Im talking about optimising here.. not standard ways for small bespoke applications Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688183 Share on other sites More sharing options...
premiso Posted November 12, 2008 Share Posted November 12, 2008 Honestly, I think you are looking at this all wrong. MySQL is built for that, how do you think this site works? or even google? They all search through databases. The trick is limiting the rows, I take it not evey user will be accessing all 100,000 rows all the time. I think you need to optimize your code or DB more. A simple messaging system you would only be pulling out messages for a certain user so you already limit the rows to those who are to that user or sent by that user. Honestly it does make sense to query the table each time, especially if you are updating the table. Sessions are nice, but it is not a realistic example. Eventually the session data has a limit and you will slow the user down with processing time then your server will be overloaded with processing time when thousand of users are accessing/reading/writing to a file system that is not nearly as efficient as a database. Trust in the database. There is a reason they are heavily used, they are quick speedy and reliable. For example a site I own, blog site that is, has over 5,000 users it generates aroun 50,000 unique hits a day with over 40,000 unique blogs with over 100,000 unique comments and it runs smooth as butter. If I am missing the point sorry, but I think you are breaking your brain for nothing. Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688189 Share on other sites More sharing options...
jaymc Posted November 12, 2008 Author Share Posted November 12, 2008 Ok, I will put faith in the database Cheers Quote Link to comment https://forums.phpfreaks.com/topic/132340-solved-unserialize-raw-session/#findComment-688204 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.