Hui WANG's Blog

One will, One way

Tag: html

A must-read story if your PHP session keeps losing weirdly

I realize that there are numerous scattered posts on the PHP SESSION LOST issu, but I’d like to add my story since it took me almost two days to figour out that php session is lost but it’s not PHP’s fault.

In the very beginning, I thought the reason why my php session is lost is because of my incorrect php code.  On lots of forums and blogs, people say that session_start() should be put in the very first line of each page, session_write_close() should come before the header redirect and also make sure that session_save_path is set in php.ini file.  Without lucks,  none of these tips could help me solve my problem. Read the rest of this entry »

Static CSS with Dynamic Element ID

We can make dynamic CSS via PHP, but it’s a little bit complicated when just a very small modification is needed. The idea, static CSS with Dynamic element id, comes from when I am trying to render a sidebar in different pages in WordPress. I’d like to show it to you with a single line php code.

<div id="sidebar_left<?php if(is_category(array(23,49,50))) echo "_small"; ?>

In the CSS file have another rule called #sidebar_left_small {} It’s DONE!