CodeIgniter Forums
loading issue after logout - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: Best Practices (
+--- Thread: loading issue after logout (/thread-63261.html)

loading issue after logout - ardavan - 10-12-2015

Hi guys,

Im currently working on a project that has member system.
At home page will appear some images from Database and the directory.
The issue is once i logout the page will redirect to home page but the images won't load and i can see the images are missing.

Im testing on my localhost.
Is the issue about my code?

Here is my logout function:
PHP Code:
function logout()


Any idea?


RE: loading issue after logout - JayAdra - 10-12-2015

How are your images being loaded? Can you post the code for them? It may be they are loaded with relative paths (e.g. images/1.jpg) rather than absolute paths (e.g. or /images/1.jpg).

RE: loading issue after logout - Baslugten - 10-12-2015

Try base_url()

RE: loading issue after logout - ardavan - 10-12-2015

I'm doing like /images/1.jpg

after change it to absolute its working well. But why this happened? is it only on localhost or if i upload on the host will be the same.
Because I'm wonder, after logout the images gone then i refresh, they appear!

Thank you for your help.

RE: loading issue after logout - mwhitney - 10-13-2015

It will be the same on the host. You should always use absolute URLs for links and src attributes, using a function like base_url() or site_url() so the correct URL is generated for the current environment.

Something else you should consider is using redirect() with no arguments rather than '/', since the slash is likely the difference between before and after you logout. In other words, since you supplied a relative URL of '/images/1.jpg' and you probably started at '', your image would be found at ''. When you called redirect('/'), you probably ended up at '', and it looks for your image at ''. Since it's fairly common for people to end up at '', you don't want this to happen when people visit the page using this URL.

You can also set the base URL in your HTML to give yourself a fixed reference for relative URLs, regardless of the URL the user is currently viewing: