Ben Lobaugh Online

I think, therefore I am. I am, therefore I sail

Tag: web development

Cookies disappear after adding Set-Cookies in .htaccess? Here is how to get them back

I needed to set a cookie via .htaccess, to ensure it was always in the browser, regardless of what the website was doing. Setting a cookie is rather easy, it will look similar to:

Header set Set-Cookie "cookieName=value; Expires=Wed, 15 May 2222 07:28:00 GMT"

The next morning I attempted to login to the site and could not. It turned out the login cookies were not being set. The issue was insidious. Re-read the line above, at first glance it seems fine when you want to set a cookie, however if there are other cookies that need to run you need to add the cookie.

This three letter change resolved the issue and allows all the other cookies to operate properly:

Header add Set-Cookie "siglock=hello-world; Expires=Wed, 15 May 2222 07:28:00 GMT"

Using wget to crawl your website

If you are looking to crawl your website for something like cache warming you can do so with wget quite easily.

The following wget command will crawl a site and leave nothing behind on the local filesystem afterward.

wget --mirror -q -e robots=off -p -r --delete-after -nd http://www.isleofmtv.com
–mirror crawls the entire site
-q prevents wget from writing output to the buffer
-e robots=off ignores directives in robots.txt
-p get all page assets
-r recursively request pages
–delete-after clean up any local files after running wget
-nd prevents wget from writing a directory structure that gets left behind

Powered by WordPress & Drip City Coffee