Jump to content
Larry Ullman's Book Forums

Session Db Table Mod

Recommended Posts

Hi Larry, and all other experts,


I am following your guide on setting up yii for my site, and I am at the stage where I want to design all the database tables before I run Gii for the CRUD/model/view/controllers setups, now I wanted to save the session data onto a database table and have as little possible info in cookies (i'd rather not use cookies unless the user specifically wants to, or i may need to to validate whether the user is using the same machine). anyway, i got the session thing to work with the mysql db and it created the table fine...


now i want to try to modify the table structure and create more fields in this table to save for instance, ip, referrer, isp, http headers, screen resolution, os, browser, etc, if i pre make these fields and call functions to read this data upon user visits, can i keep the session in the db for even if it is expired, (and then i hope to copy expired session to gather some metrics, or even for legal purposes, who was on when and where they came from (in case of criminal activity, I assume the authorities may request social networking sites to gather such statistics because it is a requirement that such sites have a report button)).


so if i sort this session table out i can then run gii, would gii include this session table too?


any tips or advice? thanks a million Larry (or others), your book has probably sold more than u think already, Yii is so nice to use, thanks to you,


Kind Regards,



Link to post
Share on other sites

Hello Deian. First, please don't ever post a message like "anyone?". This is explicitly stated in the forum guidelines, which you should read. Obviously if anyone could respond, they would have, and "anyone?" does absolutely nothing to change that. As for myself, I respond to forum postings three days a week. I meant to get to this one on Wednesday but ran out of time.


As for your situation, you can have Gii model/CRUD or not model/CRUD any database table you want. 


I would question whether it's a good idea to put all this in a session (or session table), though. Sessions are meant to be for temporary storage. By definition, if a session has expired, all the session data will (and should) be deleted.


Further, all of the information you're talking about is the kind of information that you might want to permanently know about your users (in general, not specific to any one user). And all that information is normally stored in your server logs and accessible through server statistics. 


I may not understand your exact goals, but my initial reaction is that you probably shouldn't do what you're thinking about doing.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...