Assuming $from_page
is a string value and not an array or object, sanitize_key()
should do the trick, it allows only a-z0-9_-
and I believe is used for permalink.
$cookiename = sanitize_key( 'unrestrict_'.$from_page );
setcookie( cookiename, 1 ...
there’s a whole bunch of wordpress sanitizing functions, reference available in the docs.
Related Posts:
- What is PHPSESSID?
- Setting custom cookies in WordPress
- How to set custom cookies before output
- Check if user already visited this post today
- Shortcode putting html such as
- Display message once per session to users with a specific role
- Using Cookie Data For WP_Query Loop
- Why is PHP Cookie via plugin only set when logged in as Admin and not regular users? and other questions
- How to resolve error “Cookies are blocked due to unexpected output.”?
- Using a nonce in a Custom Login Form
- Settings API – sanitize_callback is not called and it leads to an incorrect behavior
- Is it necessary to sanitize wp_set_password user input?
- Setting a cookie upon specific URL visit
- How to Highlight unread WordPress posts?
- Why is my cookie not unsetting upon logout? [closed]
- How to combine wordpress_logged_in cookies in one cookie?
- How to store post ID’s in cookie or session to display the same posts later
- how can i use $_COOKIE[] + PostID to execute the below code?
- Customizer: Category Select Sanitize
- iframe does not store session/cookie when refresh parent
- Are all hooks/functions tied to Kses meant for sanitization?
- Insert custom PHP head above in WP pages
- My php code is not being executed
- $_SESSION variable not saving on page refresh or new page
- Function sanitize_title() does not appear to be working
- How to set cookies
- Restrict characters in comment section
- How to make a cookie be on the whole site instead of being on a specific page/
- Set cookie for visitor
- Authentication from sub-folder non-wp cookie WordPress
- setcookies and header send
- Triggering a timewall after X days
- Set cookie parameters on wp site – PHP not working?
- Fatal error login WordPress [duplicate]
- IF statement not working – Any suggestions?
- Trouble matching strings (titles) using wp_query
- Customizer textarea with script tag won’t work in live preview
- Use WP user status (logged_in) to manage access to independent application
- WordPress load javascript file if something… (after the page is loaded)
- Serve cookie free URLs in WordPress without using a CDN
- Allow user to select location and then set cookie for location in WordPress
- Use WP_Query Data In Cookie
- How to set a cookie based on a page Get variable?
- Create and update Custom Cookie based on multiple GET and POST Values for first time visitors?
- Cookie not created in AJAX request
- Why can’t I enter the wordpress admin interface?
- Losing Session ID and sessionStorage when navigating to other domains on Multisite
- Keep users logged in Without Remember Me
- Why can’t I enter the wordpress admin interface?
- I can’t log into my website , it says “Error: Cookies are blocked due to unexpected output”
- Does it make sense to sanitize the output of an SVG file?
- Can’t set a cookie from php
- How to use array in function to get only value I want
- Apply class to every third list item? [duplicate]
- Only show image from custom field when present
- Cinema site, retrive the movies that actor play in
- How to include custom code on a page that’s set to act as homepage?
- retain querystring values when savincustom options in admin
- PHP if statement works in template files, but not header
- How Can I Edit the Registration Code?
- Error while setting role
- Editing a PHP file to include a small text piece on every page
- Get categories names as an array to use it in theme settings
- Should i use the wordpress Options table or to create database table..?
- variable value disappears in a second loop
- Force Users To Relogin
- unknown issue in ‘header.php’ preventing theme from displaying fully
- Hide a div to subscribers(user role) in one page (is_page)
- Security updates to 3.3.2
- Where is this function’s callback getting its arguments from?
- How can I use a sliced image As banner? [closed]
- persist a variable set in header.php all the way down to footer.php
- Echo title attribute php
- Can a page contain php code?
- Last class on last headline?
- Unable to Find Space in Custom Function
- Is it possible to display a DIV to not logged in users and then change it for users who are logged in?
- Strip Paragraph Tag
- Unable to process php via shortcode
- working with term_relationships table
- Creating a blog on my companies new website using WordPress but I have sidebar issues
- Creating a mobile site by adding a new class to the body tag from functions.php
- WordPress plug-in for dynamic download link?
- Using WP functions such as the_title() in an included php file
- GET problem in WordPress
- WordPress gallery shortag
- Almost Done… Post Format Code
- wordpress admin plugin menu custom css
- Help with page nav?
- Show recent posts starting at a specific number archive
- Add title=”” to A PHP Code
- Get Page ID from Backend
- Help with WordPress function inside a shortcode
- Wpdb->insert() doesn’t insert new row after the last one
- WordPress plugin admin page – using WordPress function in linked php file
- HTML table attributes ignored
- What’s the best way to include PHP code in pages?
- Is there any wordpress plugin to upload images and captions to multiple pages once
- How to fix this PHP warning in WP-Admin after upgrading to 3.1.2?
- PHP in Edit Post link